/ Migrations / Cutover
Docs/Migrations/Cutover

Cutover

Switch your application from the old database to the new one without downtime — and keep the old one current so rolling back is just a connection-string change.

Two ways to cut over

  • Live sync, then switch. Run a cdc migration until lag is near zero, validate, then point your app at the target and stop the sync. Simple, but once the app writes to the target the old database falls behind — rolling back means losing those writes or re-syncing.
  • Dual-write. Run a dual-write migration. When you cut over, NoSQLSync reverses direction and replicates every write on the target back to the source. If something goes wrong you can point the app back at the source with nothing lost.

Dual-write requirements

  • Source: MongoDB, DynamoDB or Firestore.
  • Target: PostgreSQL (including Supabase, Neon, RDS and Aurora).
  • The source user needs write access, because changes flow back to it after cutover.
  • The target user needs permission to create a trigger and a small outbox table — this is how NoSQLSync captures changes on the target without replication privileges.
  • Only workspace owners and admins can trigger the cutover.

Runbook

  1. Start a dual-write migration

    Create the migration with mode Dual-write and start it. It copies existing data and then streams changes, just like live sync.

  2. Wait for lag to settle

    Watch replication lag on the migration page. You want it consistently in the low seconds.

  3. Validate

    Run a validation and resolve any mismatches. Share the report with whoever signs off on the move.

  4. Cut over

    Click Cut over on the migration, or call the API. The migration must be running.

    curl -X POST https://nosqlsync.com/engine/migrations/$MIGRATION_ID/cutover \
      -H "Authorization: Bearer $NOSQLSYNC_API_KEY"

    NoSQLSync stops the forward stream, installs the trigger and outbox on the target, and starts replicating target → source.

  5. Point your application at the target

    Deploy the configuration change that switches your app's connection to the new database. Writes now land on the target and are copied back to the source.

  6. Decommission when confident

    Once you're sure you won't roll back, stop the migration. The source stops receiving updates.

✓
Rolling back

Before you stop the migration, rolling back is just pointing your application at the source again — it already has every write made on the target.

Cutover is one-way

A migration can only be cut over once. Calling cutover again returns 409 Conflict.