Skip to the page

Migrating

Moving to Napalm

A move means writing a schema, access rules and queries, then copying people, rows and files. These pages cover each step from your current platform.

API
—
In the schema
—

Parts of a move#

Six parts move from any platform. You write the first three and copy the last three.

Draft the schema and rules

Translate tables, models or collections into dbschema/default.gel with default-closed access.

Copy rows in batches

Page through existing records and import them cleanly through idempotent old_id statements.

The schema
Tables, collections or documents become types in dbschema/default.gel. A foreign key becomes a link, and a join table becomes a link to many.
The rules
Row-level security, security rules and handler checks become access rules on each type. A type with no rule is closed, so a forgotten rule never leaves data open.
The queries
SQL, ORM calls and server functions become one file each in dbschema/queries, deployed by name. napalm generate emits a typed call for every query in your language.
People
Each account becomes a person who reclaims every owned row at first sign-in. Moving your users walks through the flow.
Rows
A script reads the old system and sends batches to import statements you write. Switching over has the sender and the order.
Files
Napalm copies the bytes from any S3-compatible store into file records your schema checks.

Things left behind#

You hadHereSo
A database connection: psql, an ORM or a poolerOne HTTPS endpoint per projectSoThe app calls deployed queries over HTTPS. A project’s address speaks neither SQL nor Gel’s wire protocol.
SQL functions, triggers, PL/pgSQLStatements, rules and jobsSoA function’s computation becomes a query. A trigger’s check becomes a rule or constraint. Work a trigger kicked off becomes a job queued in the same commit.
Transactions held open across requestsOne statement per requestSoA single statement reads, inserts and updates many types at once and commits whole or not at all.
Password hashesThe project’s own sign-inSoHashes cannot be imported. People return with a magic link, a sign-in provider or a fresh password.
A key that skips every checkService keys under the same rulesSoA key reads and writes only the rows a rule grants its role. napalm keys reach measures that reach before you rely on the key.

Starting points#

Coming fromStart withCovers
Postgres with an ORM or SQLComing from PostgresCoversTables to types, the checks in your code to rules and ORM calls to queries.
SupabaseComing from SupabaseCoversRLS policies, auth.users, Storage buckets, Realtime and Edge Functions.
FirebaseComing from FirebaseCoversCollections, security rules, listeners, Cloud Functions and Firebase Authentication.
ConvexComing from ConvexCoversTables and ids, query and mutation functions, scheduled work and file storage.
GelComing from GelCoversYour schema and EdgeQL carry over. The client, the rules and the schema push process change.
Anything, with a coding agentMoving with a coding agentCoversThe files to hand the agent, its output and the commands that verify each step.

The order of a move#

Every move follows five steps, rehearsed end to end on an isolated branch before main takes a single write.

Rehearse on an isolated branch first

Push schema and queries, load a copy of your data and check real caller reach before touching main.

  1. Write the schema, the rules and the queries

    Work on a branch of a new project. napalm schema draft writes an initial schema from Postgres, Prisma or Convex, as How a schema is translated shows. napalm schema push --branch and napalm queries push --branch verify the schema and queries without touching main.

  2. Move a copy and verify the counts

    Run the move against the branch and compare its row counts with the old system. Check access as real people with napalm people reach.

  3. Turn sign-in on

    Enable the sign-in methods your users already rely on and deploy the claim query that binds each person’s rows at first sign-in.

  4. Switch

    Load main while the old system serves traffic. Pause writes on the old system, send one final pass and ship the app pointed at Napalm.

  5. Clean up

    Revoke the move’s key and remove its rules. Drop the temporary old-id fields once no query reads them.

Type a word or two to search every docs page.