Skip to the page

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 generate emits a typed function for every query in your language.
Users
Each existing account becomes a Person row 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 setupIn NapalmWhat changes
Direct SQL connections, ORMs or poolersOne HTTPS endpoint per projectWhat changesClients call deployed queries over HTTPS. Project endpoints do not expose a SQL port or Gel wire protocol.
SQL functions, triggers and PL/pgSQLQueries, rules and jobsWhat 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 transactionsOne atomic statement per requestWhat changesA single EdgeQL statement reads, inserts and updates across multiple types and commits atomically.
Imported password hashesBuilt-in project sign-inWhat 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 rulesRole-scoped service keysWhat 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 fromStart withCovers
Postgres with an ORM or SQLComing from PostgresCoversTables and object types, per-query filters moved into access rules, deployed queries and batch exports.
SupabaseComing from SupabaseCoversRLS policies, auth.users, Storage buckets, Realtime subscriptions and Edge Functions.
FirebaseComing from FirebaseCoversFirestore collections, security rules, snapshot listeners, Cloud Functions and Firebase Authentication.
ConvexComing from ConvexCoversTables and document IDs, query and mutation functions, scheduled jobs and file storage.
GelComing from GelCoversExisting .gel schemas and EdgeQL queries, default-closed access rules, HTTPS endpoints and declarative schema push.
Any stack with a coding agentMoving with a coding agentCoversExported 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:

  1. Draft the schema, access rules and queries

    Start on a branch of a new project and run napalm schema draft to generate an initial schema from Postgres, Prisma or Convex. napalm schema push --branch and napalm queries push --branch validate your schema and queries without touching main. See How a schema is translated for the generated constructs.

  2. 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.

  3. 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.

  4. Cut over to main

    Backfill main while 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.

  5. Clean up temporary migration rules

    Revoke the migration service key and delete its temporary write policies from the schema. Drop old_id properties once no script or sync worker reads those fields.

Type a word or two to search every docs page.