Migrating
Moving to Napalm
Draft a schema from your existing database, translate access rules and queries, and migrate users, rows and files with minimal downtime.
- API
- —
- In the schema
- —
What moves over#
Every migration to Napalm covers six parts. You write the schema, access rules and queries, then copy users, rows and files.
- Schema
- Tables, collections and documents become object types in
dbschema/default.gel. Foreign keys become links, and join tables become multi links. - Access rules
- Row-level security policies, security rules and handler checks become access rules on each type. A type without a rule is closed, so a missing rule never leaves data exposed.
- Queries
- SQL statements, ORM calls and server functions become named files in
dbschema/queries.napalm generateemits a typed function for every query in your language. - Users
- Each existing account becomes a
Personrow that the returning user claims at first sign-in. Moving your users walks through that claim flow. - Rows
- An export script reads your existing database and sends batches to idempotent import statements. Switching over covers batching and cutover.
- Files
- Napalm copies objects directly from any S3-compatible bucket into file records governed by your schema’s access rules.
What changes in Napalm#
| Previous setup | In Napalm | What changes |
|---|---|---|
| Direct SQL connections, ORMs or poolers | One HTTPS endpoint per project | What changesClients call deployed queries over HTTPS. Project endpoints do not expose a SQL port or Gel wire protocol. |
| SQL functions, triggers and PL/pgSQL | Queries, rules and jobs | What changesComputed logic becomes a query or computed property, validation triggers become constraints or access rules, and background work becomes a job queued in the same commit. |
| Interactive multi-statement transactions | One atomic statement per request | What changesA single EdgeQL statement reads, inserts and updates across multiple types and commits atomically. |
| Imported password hashes | Built-in project sign-in | What changesNapalm does not import external password hashes. Users return with an existing OAuth or OIDC provider, a magic link or a verified new password. |
| Superuser keys that bypass rules | Role-scoped service keys | What changesService keys read and write only the rows permitted by your access rules. napalm keys reach audits reachable row counts for any service key. |
Starting points#
| Coming from | Start with | Covers |
|---|---|---|
| Postgres with an ORM or SQL | Coming from Postgres | CoversTables and object types, per-query filters moved into access rules, deployed queries and batch exports. |
| Supabase | Coming from Supabase | CoversRLS policies, auth.users, Storage buckets, Realtime subscriptions and Edge Functions. |
| Firebase | Coming from Firebase | CoversFirestore collections, security rules, snapshot listeners, Cloud Functions and Firebase Authentication. |
| Convex | Coming from Convex | CoversTables and document IDs, query and mutation functions, scheduled jobs and file storage. |
| Gel | Coming from Gel | CoversExisting .gel schemas and EdgeQL queries, default-closed access rules, HTTPS endpoints and declarative schema push. |
| Any stack with a coding agent | Moving with a coding agent | CoversExported schema and policy files, the migration prompt and the CLI commands that verify every step. |
Order of a migration#
Every migration follows five steps. You rehearse the entire sequence on an isolated branch before main takes a single write.
Rehearse on a branch
Validate your schema, queries and imported row counts before touching production traffic.
Once the rehearsal branch passes verification, run the five stages in order:
Draft the schema, access rules and queries
Start on a branch of a new project and run
napalm schema draftto generate an initial schema from Postgres, Prisma or Convex.napalm schema push --branchandnapalm queries push --branchvalidate your schema and queries without touchingmain. See How a schema is translated for the generated constructs.Import a copy and check row counts
Run your import script on the branch and compare row counts with the old database. Verify per-user access with
napalm people reach.Configure sign-in
Enable the sign-in methods your users already rely on and deploy the claim query that links each returning user to their imported rows.
Cut over to main
Backfill
mainwhile your existing database still serves traffic. Pause writes briefly on the old system, run one final catch-up pass and deploy your app pointed at Napalm.Clean up temporary migration rules
Revoke the migration service key and delete its temporary write policies from the schema. Drop
old_idproperties once no script or sync worker reads those fields.