engineering··5 min read·WoWSQL Team

Database Migration Checklist: Cutover and Rollback Runbook

A database migration checklist and runbook for moving to WoWSQL: rehearsal, write freeze, verification queries, env and DNS cutover, and a rollback plan.

A safe database migration has five phases: rehearse on a scratch project, freeze writes on the old system, copy and verify the final data, switch the app's environment variables (and DNS, if you use your own domain), and keep the old system untouched until a rollback window has passed. This runbook applies that to a move onto WoWSQL from Supabase, Firebase, Neon, Heroku, RDS or any Postgres host. It covers who does what, the commands, the SQL checks that tell you the copy is complete, and the exact point at which you can still roll back.

The WoWSQL commands below were checked against wowsql --help for CLI 1.7.0, and the SQL was run on PostgreSQL 17 on 30 November 2026. Commands for each platform are in the source guides: Supabase, Firebase and Postgres hosts.

Key facts (checked 30 November 2026)

  • Backups: WoWSQL Free has no platform backups. Pro and Scale keep daily backups for 7 days, and support restores them (backups policy). wowsql backup create --output … saves a SQL backup on your own machine on any plan.
  • Users sign in again after any move to WoWSQL, because tokens from the old platform aren't valid and there's no documented password-hash import.
  • Data API is off by default on new projects. Enable it before cutover (Compute docs).
  • Regions: Mumbai, US East and Frankfurt. There's no UK region.

The checklist

Two weeks before: inventory and rehearsal

  • List every table, view, function, trigger, extension, cron job, bucket, auth provider, webhook and server function on the old platform.
  • Note the database size and the file storage total, and check them against the WoWSQL plan (Free: 256 MB database and 512 MB files; Pro: 10 GB database and 100 GB files; pricing).
  • Choose the region (Mumbai, US East or Frankfurt) and create the project in the dashboard.
  • Create a second, scratch project for the rehearsal.
  • Install the tools: pip install wowsql-cli, wowsql login, wowsql projects set-default <scratch-slug>, and a pg_dump at least as new as both servers.
  • Run the full migration into the scratch project and time each step.
  • Run the verification queries below and fix every difference.
  • Point a staging build of your app at the scratch project and click through sign-up, sign-in, the main reads and writes, file upload and realtime.
  • Write down the measured times. They set your maintenance window.

One week before: prepare the cutover

  • Set up auth providers on the production project (OAuth client IDs and secrets, callback https://<slug>.wowsqlconnect.com/auth/v1/oauth/<provider>/callback).
  • Add the new redirect URIs in each provider console, next to the old ones.
  • Enable the Data API and expose the tables the app calls.
  • Store server secrets: wowsql secrets set KEY "value".
  • Prepare the new environment variables in your hosting platform without deploying them yet (WOWSQL_PROJECT_URL, WOWSQL_ANON_KEY, plus WOWSQL_SERVICE_KEY and DATABASE_URL on the server only).
  • If you use a custom API domain or CNAME, lower its DNS TTL to 300 seconds now, so the change spreads quickly on the day.
  • Tell users about the maintenance window and that they'll need to sign in again (and reset their password, if they used email and password).
  • Copy files that never change ahead of time with your storage script, so cutover only syncs new files.

Cutover day: the runbook

# Step Command or action Rollback possible?
1 Back up the target wowsql backup create --name pre-cutover --output ./backups/pre-cutover.sql Yes
2 Turn on maintenance mode or a read-only banner App feature flag Yes
3 Freeze writes at the source Revoke write grants, use deny-write rules (Firebase), or stop workers Yes
4 Final source backup pg_dump "$SOURCE_DB_URL" --format=custom --file=final-source.dump Yes
5 Load the final data into a clean target Restore as rehearsed (pg_restore / psql, or wowsql db restore --file …) Yes
6 Sync files changed since the pre-copy Storage script Yes
7 Verify Queries below; wowsql db tables list; smoke tests Yes
8 Deploy the new env vars and update DNS Hosting dashboard; DNS provider Yes, by redeploying the old env
9 Re-enable writes, now on WoWSQL Turn off maintenance mode After this, rollback needs data copied back
10 Watch errors, auth failures and 403s for 48 hours Logs: wowsql logs view, wowsql status Copy-back only

Step 9 is the point of no return. Before it, rolling back means redeploying the old environment variables and lifting the source freeze. After it, any rows written to WoWSQL must be copied back to the old system before you switch.

Verification queries

Run each one on the source and on WoWSQL and compare the results. They work on any PostgreSQL 12 or later. For Firebase, compare against your export counts instead.

set timezone = 'UTC';

-- 1. Exact row count per table
select table_schema, table_name,
       (xpath('/row/c/text()',
              query_to_xml(format('select count(*) as c from %I.%I', table_schema, table_name),
                           false, true, '')))[1]::text::bigint as row_count
from information_schema.tables
where table_type = 'BASE TABLE' and table_schema = 'public'
order by 1, 2;

-- 2. Content fingerprint for key tables (repeat per table; order by its primary key)
select md5(string_agg(t::text, '|' order by t.id)) as fingerprint from public.orders t;

-- 3. Newest row: confirms the final copy happened after the freeze
select max(created_at) from public.orders;

-- 4. Sequences have not fallen behind the data
select sequencename, last_value from pg_sequences where schemaname = 'public';

-- 5. RLS is on everywhere the API can reach
select c.relname as table_without_rls
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind = 'r' and not c.relrowsecurity;

-- 6. Policies came across
select tablename, policyname, cmd from pg_policies where schemaname = 'public' order by 1, 2;

-- 7. Functions and triggers came across
select count(*) as functions from pg_proc p join pg_namespace n on n.oid = p.pronamespace where n.nspname = 'public';
select count(*) as triggers  from pg_trigger t join pg_class c on c.oid = t.tgrelid
  join pg_namespace n on n.oid = c.relnamespace where n.nspname = 'public' and not t.tgisinternal;

From the CLI, wowsql db query --file verify.sql sends the file to the API. If it shows only part of the output, run the queries one at a time with wowsql db query "…", or use psql.

Then run the app-level checks:

  • Sign up a new user, sign in, sign out, and reset a password.
  • Sign in as two different users and confirm each sees only their own rows (this tests RLS through the API, not as the database owner).
  • Upload a file to each bucket and load a public file URL.
  • Trigger a realtime event and see it arrive.
  • Call each server function.
  • Look for 403 DATA_API_DISABLED. It means the Data API or a table isn't exposed yet.

Rollback plan

Write this down before cutover and assign one person to decide.

  1. Trigger: for example, more than N failed sign-ins in 15 minutes, any data mismatch, or a 5xx rate above your threshold.
  2. Before step 9: redeploy the old env vars, put the old DNS record back (a TTL of 300 makes this quick), and lift the source write freeze. Nothing is lost.
  3. After step 9: put WoWSQL in maintenance mode, export the rows written since cutover (by created_at/updated_at, or wowsql db export <table> --output rows.csv --format csv), apply them to the source, then switch back.
  4. Keep the source paused or read-only, not deleted, for at least two weeks. On WoWSQL, deleting a project deletes its backups too (backups policy).

Downtime planning

Plan the write freeze to fit the time steps 3 to 9 took in your rehearsal, plus a buffer. Reads can usually continue from the old system during the freeze. If even a short freeze is unacceptable, ask WoWSQL support before you plan for logical replication, because the public docs don't describe it.

After the move

  • Schedule your own backups: wowsql backup create --output ./backups/$(date +%F).sql from cron, or pg_dump on a schedule. Free has no platform backups.
  • Put schema changes into migration files: wowsql migration new <name>, wowsql migration up --dry-run, wowsql migration up.
  • Regenerate types: wowsql gen typescript --output ./src/types/database.ts.
  • Remove the old platform's keys from CI and hosting.
  • Run through the BaaS security checklist.

FAQ

What should a database migration checklist include?

An inventory of everything on the old system, a full rehearsal on a scratch project, backups of both sides, a write freeze, a final copy, verification queries (row counts, fingerprints, sequences, RLS, policies), an environment and DNS switch, and a written rollback plan with a point of no return.

How do I verify a Postgres migration is complete?

Compare exact row counts per table, an md5 fingerprint of each key table, the newest created_at, sequence values, and the lists of RLS policies, functions and triggers on the source and target. Then test sign-in and per-user data access through the API.

How do I roll back a failed database migration?

Before writes resume on the new system, redeploy the old environment variables and DNS and lift the freeze on the old database. After writes resume, export the new rows from the new system and apply them to the old one before switching back. Keep the old system read-only, not deleted.

How long should the maintenance window be?

As long as steps 3 to 9 took in your rehearsal, plus a buffer. Time each step on a scratch project with production-sized data. Database size and file count are what drive it.

Do users have to log in again after migrating to WoWSQL?

Yes. Sessions from the old platform aren't valid on WoWSQL, and there's no documented password-hash import, so plan a sign-in or password-reset prompt and tell users in advance.

Related guides

Create a free WoWSQL project to use as your rehearsal target. · Pricing · Backups policy