SupabaseMigrations and upgradesguide
Upgrade a Supabase project to a new Postgres major version, end to end
What you will do
Section titled “What you will do”Upgrade a Supabase project to a new Postgres major version (e.g. 15 -> 17) with minimal risk. Three paths - pick one:
| Path | Downtime | Reconfiguration after | Pick when |
|---|---|---|---|
| A: upgrade in place, rehearsed on a clone | a write-stop window of minutes, barely growing with size: timed 2026-11-09 on Small, 15.19 -> 17.11, 17.11 first answered at +318.8 s (0.06 GB) and +344.6 s (3.65 GB) after the POST, and writes had to stay stopped until then. What grew with size was the tail to ACTIVE_HEALTHY (337.4 s and 633.1 s), with 17.11 already answering. The earlier reading of ~10 s per GB of disk plus fixed overhead (derived not measured) is not supported by these runs - see measured runs | none - same project, URL, keys, JWT secret | the default, for almost everyone |
| B: cut over to a new PG 17 project with pgmig | seconds (replication lag drain) | the full new-project list (table below) | downtime budget is smaller than the in-place window; very large database; the upgrade doubles as a region move |
| C: Docker pg_upgrade lab | n/a - rehearsal only | n/a | you want the blocker audit + a timing feel without creating anything billable; complements A |
Path A is the two dashboard flows run in order: rehearse on a throwaway Restore to a New Project clone, then run the real thing in place on production. Path B is logical replication orchestrated by pgmig (named sbshift until 2026-09-28; schema pre-step, replicate/watch, checksum reconcile, write-stop cutover - the tool’s own scope, gates and rollback phases are in the pgmig reference); it lands on a new project - new ref, new API keys, new JWT secret, the same reconfiguration burden as the clone column below - and it is the only cross-region path (see the region-migration guide). Path C is pgmig’s local Docker rehearsal aid. For any task in any path, the three-ways matrix shows the manual, UI/API, and pgmig method side by side.
Prerequisites: a paid plan (physical backups enabled; PITR recommended), the
Supabase dashboard, and optionally rclone or aws-cli if your rehearsal
needs real storage files. Behaviour in this guide was validated against the
live platform on 2026-07-29 (clone from PITR, then byte-level and config-level
checks on the clone) and 2026-07-30 (full pgmig pipeline against a throwaway
cross-region pair, plus a Docker pg_upgrade lab); anything not re-verifiable by
you in an hour is marked as such.
The clone flow and the in-place upgrade are different operations. A clone is a new project - new project ref, new API keys, new JWT secret, and a pile of project-level settings that do not come along. The in-place upgrade swaps the instance underneath your existing project - nothing about how clients connect changes. Do not mix the two checklists.
What carries over and what does not
Section titled “What carries over and what does not”Validated 2026-07-29 by seeding a source project (public + private buckets,
custom schema exposed in the Data API, pgjwt, a live pg_cron job, SMTP
markers) and restoring it to a new project. The “clone” column is measured;
the “in-place” column follows from the upgrade being a same-project instance
swap.12
Re-verifying the table is limited in two ways, established 2026-08-03. The clone
has no Management API endpoint - database/backups, restore, restore-pitr,
restore-point, undo and schedule all act on the same project, and nothing
creates a project from a backup, so this flow is a dashboard click and environment
creation cannot be scripted through it. Probed 2026-10-10 on one fresh Pro project
(RP01), two of those in-place routes did not answer: POST database/backups/restore
and GET database/backups/restore-point returned 400 with the body
“This endpoint is unavailable at the moment”, and a manual call (no artifact) on
a project with pitr_7 applied returned the same. restore-pitr was the
in-place route that ran, on separate Small Pro projects with pitr_7 (RP02);
older projects and other organisations were not tried, and the DR tiers
page has the per-path timings. A project created for the occasion
cannot be cloned either, because the clone needs a completed physical backup and backups
are daily. Re-checking the table therefore needs an existing project rather than
throwaway infrastructure. Thirteen of the clone-column rows below are independently
corroborated by Supabase’s own clone documentation.2 Four were
re-measured on 2026-08-04 against a different source and held: same region, new
anon key, auth settings reset to defaults, auth.users copied intact.
| Item | In-place upgrade (prod) | Restore to a New Project (clone) |
|---|---|---|
| Project ref / API URL | unchanged | NEW - update client env |
| anon / service API keys | unchanged | NEW |
| JWT signing secret | unchanged | NEW (existing sessions invalid on the clone) |
| Schema, data, indexes, roles | upgraded in place | copied |
auth.users (accounts, hashed passwords) | kept | copied |
| Vault / encryption root key | kept | copied |
| Compute + disk attributes | unchanged | mirrors source at clone time |
| Region | unchanged | same as source |
| Storage buckets + object metadata | untouched | copied - storage.buckets and storage.objects rows live in the database, so they come across even though the docs say “bucket configurations are not copied”2 |
| Storage file bytes | untouched | NOT copied - the object row arrives, the bytes do not. Re-confirmed 2026-08-04; the body says 404 NoSuchKey while the wire status is 400, so assert on the body |
| Auth settings (SMTP, templates, site/redirect URLs) | untouched | NOT copied - reset to defaults |
| Data API exposed schemas | untouched | NOT copied - reset to public,graphql_public |
| Edge Functions + secrets | untouched | NOT copied |
| Realtime settings | untouched | NOT copied |
| Read replicas | must DELETE before, recreate after | NOT copied |
Deprecated extensions (e.g. pgjwt on PG 17) | must drop before | carried - drop on the clone too |
pg_cron / pg_net jobs | n/a | carried and still active, and they fire within minutes (see below) |
| Using the clone as a source for another clone | n/a | not supported - a restored project cannot itself be cloned2, though it does get physical backups of its own within a minute of coming up |
| Data currency | n/a - upgraded in place | as of the backup you pick rather than the moment you click - with PITR, the instant you pick |
| Vault secrets | kept | copied, and they decrypt - the encryption root key travels2 |
| A non-default Data API schema | untouched | the SCHEMA and its rows copy; only the exposure config resets, so it is present but unreachable over PostgREST |
| PITR on the clone | n/a | not inherited - a clone of a PITR project comes up with daily backups |
| Custom roles with md5 passwords | reset or they fail post-upgrade | same on the clone after its upgrade |
| Logical replication slots | must drop before | n/a |
Clone cron jobs fire before you get to them
Section titled “Clone cron jobs fire before you get to them”Measured 2026-08-04, a source with two jobs on */5 and */15 schedules
produced a clone where both arrived active = true and both fired and succeeded
at the first matching tick, six minutes after the clone came up - before anyone
could have opened the dashboard to disable them. The interval between a clone
existing and its jobs running is one cron tick, so disabling them belongs in the
clone procedure itself.
The risk depends on what the job does. Jobs that only touch
their own database are harmless on a copy - they delete the clone’s rows.
pg_net, wrappers, or anything calling an external API are the problem: those
run from the clone against whatever they were pointed at, which is production,
on a schedule nobody chose.2
cron.job_run_details is copied like any other table - the clone here inherited 40,843 run records going back four
months - so a clone appears to have been running its jobs for as long as the
source has. Filter on a start time after the clone was created to see what the
clone itself did.
The clone is a copy of a backup, not of the project
Section titled “The clone is a copy of a backup, not of the project”Nothing in the flow warns you how far behind the source the clone is. It is restored from a backup you select, and without PITR the newest one available is the last daily.
Measured 2026-08-04: the source’s newest physical backup was 18:43Z, the clone was created 04:33Z the next morning - 9 h 50 m later - and nine of ten tables matched exactly. The tenth was short a single row, written at 00:01Z that morning: after the backup, before the click, present on the source, absent on the clone. Under real traffic, every write in that window is missing from the clone.
With PITR you get a date-and-time selector instead of a list of dailies,2 and measured 2026-08-04, it closes the gap to the instant you pick. A project was seeded two and a half hours after its newest daily backup; a clone taken with the selector came up carrying every seeded artifact, where the same clone without PITR would have had none of them.
The restore itself still takes time: that clone took 150 s to reach
ACTIVE_HEALTHY (the two non-PITR ones took 100 s and 180 s), and a source under
real traffic keeps writing throughout. The clone does not inherit PITR -
it comes up with ordinary daily backups, so the copy is protected differently
from the thing it was copied from.
Turning PITR on has its own cost. It is refused below Small compute, and the
Micro -> Small resize that gets you there took REST reads down for
231.465 s, with Auth and Realtime joins within 4 s of it and the status
reading ACTIVE_HEALTHY at 218 s; the Small -> Micro step back took REST
reads down for 254.886 s (Realtime joins 244.941 s) (compute-disk D09,
2026-10-23, 250 ms sampling, n=1 per op). The addon
endpoint rate-limits consecutive
changes, so the compute change and the PITR change cannot be applied back to
back.
For a rehearsal, being a few hours behind production changes nothing. Used as a migration, the clone needs writes stopped at the chosen instant, a reconcile of the delta afterwards, or a copy method that streams rather than snapshots.
Storage: metadata copies, bytes do not
Section titled “Storage: metadata copies, bytes do not”Object URLs are constructed from the project that serves the request - they are not stored as absolute URLs - so on a clone every file appears under the new project ref and the dashboard looks complete. But the bytes live in S3 keyed by the source project and are not copied:3
- pre-existing files return 404 under the clone’s ref (public URLs, nested paths, and signed URLs alike);
- files you upload to the clone work fine;
- deleting the source project breaks every old file on the clone.
If your rehearsal needs the real files, sync them over the S3-compatible endpoint (per-project access keys under Settings > Storage):
export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=...# download from source, then upload to clone (or rclone remote-to-remote)aws s3 sync s3://my-bucket ./restore-staging \ --endpoint-url https://SOURCE_REF.supabase.co/storage/v1/s3aws s3 sync ./restore-staging s3://my-bucket \ --endpoint-url https://CLONE_REF.supabase.co/storage/v1/s3Bucket metadata is already on the clone, so the targets exist. If the rehearsal only needs the API surface (upload + retrieval paths), skip the sync and treat old-file 404s as expected.
The sync has a limit on key names. Measured 2026-10-10 on one Pro project per run (SS02, n = 3 runs on fresh projects, ap-southeast-1), with the AWS SDK for JavaScript v3 using the session-token form (access key id the project ref, secret the anon key, session token the service_role JWT4), 40 keys went through put, head, get, list, presigned GET, copy, a one-part multipart upload and delete. The split was the same on the gateway host and the direct storage host, on Bun and on Node:
| Result on the S3 endpoint | Keys | Which |
|---|---|---|
| every operation round-trips | 18 | plain, space, +, =, &, ,, ;, @, :, $, !, ', parentheses, *, ?, a nested path, a leading space, a trailing space |
400 InvalidKey on put | 19 | keys containing %, #, ~, [ ], { }, ^, |, a backtick, < >, ", \, a tab, and every non-ASCII key tried (NFC and NFD, CJK, an emoji, a 204-character multibyte key) |
403 SignatureDoesNotMatch | 3 | a//b.txt, dot/./seg.txt, dot/../seg2.txt |
A bucket that holds keys outside the first row cannot be synced key for key over
the endpoint: the upload to the clone is refused for 22 of the 40 keys tried. A
REST GET of the refused keys returned the same InvalidKey body; the REST
upload for them was not recorded. The three 403 keys are refused by the
endpoint, not only by a client: on Node the request line equalled what was
signed and the answer was still 403, and on Bun the dot-segment keys were
rewritten by the client after signing, which a local control showed. The error
codes page lists InvalidKey without the accepted characters,5
so this split is the only statement of them here, for this Storage server on
2026-10-10. Not measured: dashboard-generated S3 access keys (no API route found
that creates them), an Amazon S3 control for the three 403 keys, and any
client other than the AWS SDK v3 and supabase-js. Compare
storage.objects.name for the bucket against these classes before the window;
the Storage surface reference carries the
rest of the SS02 findings.
Data API schema exposure is project config, not data
Section titled “Data API schema exposure is project config, not data”The Exposed schemas setting (Settings > API) is PostgREST db_schema
configuration, which is project-level config - it is not in Postgres, so a
physical restore cannot carry it. Your schemas, tables, and data all arrive;
the clone just does not expose them until you re-add them under
Settings > API. Symptom if you forget: 406 PGRST106 / “Invalid schema”
errors from the Data API against an otherwise fully restored database.
An empty list fails differently: PostgREST cannot build a schema cache at
all, so it serves a steady 503 PGRST002 retry loop (measured) and takes
/graphql/v1 down with it. Check the exposed-schemas list before chasing
that as an outage.
The same applies to every Auth setting - SMTP credentials, email templates,
site URL, redirect URLs - all reset to defaults on a clone.
The Automatically expose new tables toggle (Integrations > Data API
settings, a.k.a. “Default privileges for new entities”) does not help here: it
only auto-grants new tables and functions in an already-exposed schema - it never exposes a new schema. Its mechanism is ALTER DEFAULT PRIVILEGES, which lives in Postgres, so those grants do survive a clone;
the schema list does not.6
pg_cron jobs come along running
Section titled “pg_cron jobs come along running”Extensions themselves are in the database, so they copy - including
deprecated ones like pgjwt (which then blocks the clone’s own PG 17
upgrade until dropped). The pg_cron jobs copy active, as above; disable
them before anything else:
select cron.unschedule(jobid) from cron.job; -- or selectively:select cron.alter_job(<jobid>, active := false);The same caution applies to pg_net, wrappers, and anything else that
performs external side effects.2
TimescaleDB: plain hypertables only, and the conversion guide’s order (PX01)
Section titled “TimescaleDB: plain hypertables only, and the conversion guide’s order (PX01)”timescaledb falls under the deprecated-extensions row of the table above,
and its hypertables hold rows, so they are converted before the extension is
dropped. The extension page says timescaledb is deprecated on Postgres 17
and must be dropped before a 15 project is upgraded, and for hypertables points
to a migration guide that converts them to native partitioning managed by
pg_partman.7 That guide renames the hypertable, creates
(like ... including all, primary key (sent_at, id)) partition by range (sent_at), copies with insert ... select *, drops the hypertable and then
the extension once every hypertable is migrated, and only then, in an
optional last step, calls partman.create_parent.8 Both pages read that way on
2026-11-10 and 2026-11-11.
PX01 ran that guide, a corrected order and two logical-replication moves on
2026-11-10, one run
(RUNLOG):
a source on 15.19 (postgres_engine: "15") and a target on 17.11, both at the
compute size the API assigns when none is set (the artifact’s title says Micro,
which was not read back), in ap-southeast-1 on a Team-plan org. The source held
two hypertables of 300,000 rows each in 1-day chunks over 30 days: messages
(id bigint generated always as identity, primary key (id, sent_at)) and
events (no primary key).
create extension timescaledb with schema extensionson 15.19 installed 2.16.1 withtimescaledb.licenseapache, which matches the extension page’s statement that projects come with the Apache 2 Edition and that Community Edition functionality is not available.7 Compression and a continuous aggregate were each refused with SQLSTATE 0A000functionality not supported under the current "apache" license, andadd_retention_policywith 0A000function "add_retention_policy" is not supported under the current "apache" license. Changing the setting was not tested. Atapachea project holds plain hypertables only, so there is no compressed data to expand and no aggregate to rebuild before a move. 17.11 does not listtimescaledb; both listpg_partman5.3.1 andpg_cron1.6.4 (PX01a to PX01c).- With the extension installed,
GET /v1/projects/{ref}/upgrade/eligibilityansweredeligiblefalse withvalidation_errors[{"type":"unsupported_extension","extension_name":"timescaledb"}]; after the drop it answeredeligibletrue with[](PX01d, PX01h). - A hypertable does not replicate as-is. A publication on
messageslisted 32 tables inpg_publication_tables, 31 of them the chunks in_timescaledb_internal, andcreate subscriptionon 17.11 into a plainpublic.messagesfailed with SQLSTATE 3F000schema "_timescaledb_internal" does not exist. The target held 0 rows 60 s later, and 0 of the 200 rows written on the source after that (PX01e). - The guide as written failed on both shapes (PX01f). On
messages,create table public.messages (like public.ht_messages including all, primary key (sent_at, id)) partition by range (sent_at)failed with SQLSTATE 42P16multiple primary keys for table "messages" are not allowed. Oneventsthe create succeeded, and the copy, which the guide runs beforecreate_parent, failed with SQLSTATE 23514no partition of relation "events" found for row.
Three changes made the conversion work on both tables (PX01g): call
create_parent before the copy; when the hypertable already has a primary key,
replace including all with including defaults including constraints including identity including generated and keep the guide’s primary key (sent_at, id); and for a GENERATED ALWAYS identity column, copy with
overriding system value (a plain insert ... select * failed with SQLSTATE
428C9) and move the sequence past max(id) afterwards. events, with the
guide’s including all create and create_parent first, took 300,000 rows in
2178 ms into 39 child partitions including the default, with 0 rows in the
default. messages took 300,200 rows in 1294 ms, 100 of them in the default
partition: rows dated 10 days ahead, past the 7 premade days. The order for
messages, as the module ran it:
-- Postgres 15 project; messages: id bigint generated always as identity,-- primary key (id, sent_at)alter table public.messages rename to ht_messages;
create schema if not exists partman;create extension if not exists pg_partman with schema partman;
-- with a primary key on the hypertable, the guide's "including all" gave 42P16create table public.messages (like public.ht_messages including defaults including constraints including identity including generated, primary key (sent_at, id)) partition by range (sent_at);
-- before the copy (the guide's order gave 23514)select partman.create_parent(p_parent_table := 'public.messages', p_control := 'sent_at', p_type := 'range', p_interval := '1 day', p_premake := 7, p_start_partition := '<first day of the data>');
-- a plain insert ... select * gave 428C9 on the GENERATED ALWAYS columninsert into public.messages overriding system value select * from public.ht_messages;
select setval(pg_get_serial_sequence('public.messages', 'id'), (select max(id) from public.messages));
drop table public.ht_messages;drop extension if exists timescaledb; -- once every hypertable is convertedcall partman.run_maintenance_proc();create extension if not exists pg_cron;select cron.schedule('@daily', $$call partman.run_maintenance_proc()$$);Skipping the setval fails without an error: the next insert got id 1 while
max(id) was 300200, 2 rows then had id 1, and the primary key (sent_at, id)
accepted it. After the setval the next insert got 300201. Dropping both
hypertables, drop extension timescaledb, call partman.run_maintenance_proc()
and the guide’s cron.schedule line (job 1) all succeeded.
After the conversion the table replicates (PX01i). create publication px_np for table public.messages with (publish_via_partition_root = true) on the
source and a subscription on 17.11 into a plain public.messages had every
table r at the first 10 s check, with 300,202 rows on both. 100 rows dated
3 days ahead (a premade partition) and 100 dated 30 days ahead (the default
partition, which then held 200) reached the target within 30 s: 300,402 rows,
100 and 100. On either path, then, the conversion happens on 15 first: Path A
drops the extension and reads eligibility, and Path B publishes the partitioned
table through its root.
Not measured: a copy at production size (the 2178 ms and 1294 ms above are one
sample each), what writers see between the guide’s rename and the copy,
application SQL that calls time_bucket() or other timescaledb functions,
hypertables with foreign keys or space partitioning, what the 3 jobs in
timescaledb_information.jobs were, pg_partman retention, dropping the
guide’s primary key (sent_at, id) clause instead of narrowing the like
list, and an in-place upgrade after the conversion (eligibility only).
Every task, three ways
Section titled “Every task, three ways”Every way of landing on a new Postgres major - or a new project - reduces to
the same task list. Each task has three methods: the manual checklist
(raw SQL + dashboard clicks), the UI/API method (dashboard flows, the
Management API, the supabase CLI), and the pgmig method (the
orchestrated pipeline).
| Task | Manual checklist | UI / API | pgmig |
|---|---|---|---|
| Create the target project | dashboard > New project | supabase projects create / POST /v1/projects | sandbox up (rehearsal pair) |
| Enable extensions | dashboard > Database > Extensions | SQL create extension | bootstrap (auto-diffs the source) |
| Restore roles + schema | pg_dumpall --roles-only + pg_dump --schema-only into psql | supabase db dump (roles / schema) | bootstrap --confirm |
| Copy auth users | pg_dump --data-only --schema=auth --exclude-table-data=auth.schema_migrations, restore in one transaction with session_replication_role = replica | supabase db dump --data-only --schema auth -x auth.schema_migrations | bootstrap --with-auth-data |
| Move table data | pg_dump --data-only + restore (downtime = full copy time) | dashboard > Restore to a New Project (same region only) | replicate + watch (consistent copy + WAL stream) |
| Verify data identical | count(*) per table | - | reconcile (chunked checksums) |
| Copy project config (auth, realtime, postgrest, storage, pooler) | transcribe the dashboard settings pages | Management API GET/PATCH per endpoint | config-sync |
| Copy secrets (function env, integration creds) | dashboard re-entry | POST /v1/projects/{ref}/secrets | configSync.projectSecrets (opt-in) |
| Create storage buckets | dashboard > Storage > New bucket | POST /storage/v1/bucket | the storage push auto-creates them (lands private) |
| Move storage bytes | rclone / aws s3 sync over the S3 endpoint | supabase storage cp | storage <localDir> |
| Deploy Edge Functions | paste in the dashboard editor | supabase functions deploy --project-ref | functions |
| Re-create cron jobs | re-run cron.schedule(...) by hand | same - SQL only, no automation anywhere | same |
| Match compute size | dashboard > Settings > Compute | PATCH /billing/addons | provision |
| Health-check the target | dashboard > Advisors | Management API advisors endpoint | verify |
| Cut over | stop writes, repoint app env by hand | same | cutover (quiesce check, lag drain, sequence resync) |
| Retire the old project | dashboard > Settings > Delete project | DELETE /v1/projects/{ref} | teardown; sandbox down for rehearsals |
Path A: upgrade in place (default)
Section titled “Path A: upgrade in place (default)”Rehearse on a clone
Section titled “Rehearse on a clone”This has no user impact. The clone upgrade previews the exact blocker list and time estimate the production upgrade will show you, so run it even when the production run looks trivial.
- Clone. Source project -> Database -> Backups -> Restore to a New Project -> pick the latest PITR point (or a daily backup). Note the cost preview: the clone mirrors your source’s current compute and bills until deleted. A clone cannot itself be a clone source.2
- Sanitise the clone (before it does anything):
- unschedule / deactivate
pg_cronjobs (they copied over active), - drop
pgjwtand any other extension deprecated on your target version, - drop leftover logical replication slots, if any.
- unschedule / deactivate
- Reconfigure the clone (the part that is always manual):
- new API keys -> your preview/staging deployment env,
- SMTP provider + sender details (Auth > SMTP),
- re-expose custom schemas (Settings > API),
- email templates, site URL, redirect URLs.
- Optionally sync storage bytes (see above) if validation needs them.
- Upgrade the clone: Settings > Infrastructure > Upgrade project -> target version. Read the blocker list and the downtime estimate before confirming - this is the same pre-flight the production project will get.
- Validate with your app against the target Postgres version:
- login flow + JWKS endpoint,
- your heaviest write paths,
- storage upload and retrieval,
- any custom-schema Data API calls,
- watch the query logs for plan regressions.
- Green -> schedule the production window. Red -> debug on the clone.
If you want a production-data seed for preview branches instead of the clone
flow, the documented one-liner is
supabase db dump --data-only --linked > supabase/seed.sql - branches run
seed.sql once at creation.910
Optional: rehearse pg_upgrade itself in Docker (pgmig upgrade lab)
Section titled “Optional: rehearse pg_upgrade itself in Docker (pgmig upgrade lab)”The clone rehearsal previews the blocker list and the platform time
estimate, but it cannot tell you how long the pg_upgrade step itself takes
on data shaped like yours, and it costs a mirrored-compute project while it
exists. pgmig’s upgrade rehearsal
runs the whole thing locally in Docker, for $0, with no project at all:
bun start upgrade doctor --to 17 # read-only blocker audit of the sourcebun start upgrade capture --out-dir capture # dump roles + schema + databun start upgrade lab --capture-dir capture --runs 3 --keepbun start upgrade verify # prove the upgraded cluster is data-identicalupgrade lab loads your captured data (or a synthetic fixture via
--seed-gib) into a PG 15 container, snapshots the data directory, then runs
pg_upgrade --link to PG 17 N times from a fresh snapshot each time, followed
by post-upgrade ANALYZE, and emits a timing report. upgrade verify
chunked-checksums the pre-upgrade source against the upgraded cluster.
Measured 2026-07-30 on a 0.23 GiB fixture (this machine, 15 -> 17, 3 runs):
pg_upgrade --link itself took 3.7s per run (+ ~1.2s analyze, ~4-6s
initdb/prep). At real database sizes pg_upgrade --link is rarely the bottleneck. The upgrading guide ties the in-place
upgrade’s duration to disk throughput instead - “A Supabase project is deployed
with a GP3 disk type by default, which will give ~100Mbps when upgrading” - and
derives the downtime window from database size at that rate.1
The lab also accepts --prod-bytes <n> to fold that copy-time estimate into
its report.
The figure reads two ways. As megabytes per second it sits just under the gp3
default of 125 MB/s,11 and at 100 MB/s a copy costs about
10 s per GB, or a little under 3 hours per TB; this page used that reading
until 2026-11-09. As megabits it is eight times slower, about 1.3 minutes per
GB, which a version of this page before 2026-11-09 used. The two tabulated
upgrades from 2026-11-09
(measured runs) fit the
megabit reading, for the tail after the upgrade: the time between
9_completed_upgrade and ACTIVE_HEALTHY grew from 20.4 s at 0.06 GB to 296 s
at 3.65 GB, 276 s more for 3.59 GB more, about 77 s per GB against 80 s per GB
for 100 megabits a second (derived from two points, one run each; inference).
During that tail 17.11 was already answering, and the data-upgrade stage
barely moved (122.5 s and 142.8 s), so the window in which writes had to stay
stopped was minutes and barely grew with size: 17.11 first answered at
+318.8 s and +344.6 s, while the longest runs of failed samples inside it were
10 s and 35.1 s. In these runs the size-dependent part delayed ACTIVE_HEALTHY while
the database answered; whether the Data API answered during it was not tested
(the sampler used the session pooler only). The 10 s per GB reading is not
supported by these runs. A throughput ceiling bounds one phase rather than
measuring downtime, and the smaller compute sizes have baseline disk
throughput well under 100 MB/s, so a copy can run slower there.
The eligibility endpoint does not corroborate the scaling. Read on 2026-08-04,
duration_estimate_hours came back as a flat 1 on three small projects, each offering a single patch-level target.
If the published estimate scaled with disk at that size, three different
projects would not all report the same integer - so either the field is a
floor, or it is coarse, or it does not scale the way this derivation assumes.
On 2026-11-09 the field read 1 for a real 15 -> 17 target at 0.06 GB and at
3.65 GB, on upgrades that reached ACTIVE_HEALTHY 337.4 s and 633.1 s after the
POST. Treat a per-GB rate as a planning figure for the tail before
ACTIVE_HEALTHY, with a slope taken from two points.
Use the lab when you want the blocker audit + a timing feel without creating anything billable; use the clone when you need to validate your app against the real platform. They complement each other - the lab has no Data API, no Auth, no storage.
Run the production upgrade
Section titled “Run the production upgrade”None of the reconfiguration list above applies here - the project, URL, keys, JWT secret, auth settings, and storage stay exactly as
they are. What changes is the Postgres version (and the rest of the service
stack images). Mechanics: the project goes offline, a new instance is
provisioned, data is copied (the guide’s “~100Mbps” on the default disk; what
that rate means in practice is under the Docker
rehearsal),
pg_upgrade runs, platform validations run, a base backup is taken,
and the project comes back. If the upgrade fails, the original database is
brought back online automatically.1
In the two 2026-11-09 upgrades with a completed survival check, “offline” left the session pooler taking writes for most of the window: its longest run of failed connections was 10 s at 0.06 GB and 35.1 s at 3.65 GB, out of more than five minutes before 17.11 answered. The 15.19 server came back with a new postmaster start time two or three times, and every absent write had been acknowledged by the last of those restarts (measured runs). Stop every writer before the POST and keep it stopped at least until the database answers on the new major.
Version-specific caveats to check first
Section titled “Version-specific caveats to check first”The upgrade screen does not raise the first four caveats as
blockers.1 The last two rows come from the 15.19 / 17.11
changelog,12 and whether the upgrade screen raises them
was not checked. The pg_graphql row carries figures measured 2026-10-10 on one
Pro project created through the Management API (DD02, Postgres 17.11,
ap-southeast-1). The ltree, estimator, pgcrypto and btree_gist rows carry
figures from a local Docker run on the same day, described under the table.
| Caveat | Who is affected | Do this |
|---|---|---|
cron.job_run_details bloat | anyone using pg_cron without pruning | Prune it before the window. The in-place upgrade carries the pg_cron catalog through pg_upgrade (cron.job, job_run_details history, jobids and sequences survive; UI01-UI06, 4 runs, 15 to 17). A huge job_run_details table still adds disk pressure that degrades or fails the upgrade, and VACUUM FREEZE after it also costs for its size. |
| pg_graphql 1.6.0 disables introspection | anyone whose tooling calls __schema / __type (GraphiQL, graphql-codegen, Relay) | Re-enable per schema after the upgrade: comment on schema public is e'@graphql({"introspection": true})'; - merge with existing directives, a new comment overwrites the old. Data queries are unaffected. Measured 2026-10-10 on 1.6.2 (DD02): __schema and __type answer HTTP 200 with Unknown field until the comment sets introspection true, and false refuses them again. Probe with { __typename } and read the body: the status is 200 whether the extension is absent, enabled without the comment, or enabled with it. A new project has no pg_graphql at all; the per-key probes are in the data surface lockdown reference. |
ltree indexes need a rebuild | upgrades to 15.18 / 17.10 on a multibyte encoding (UTF-8) or a non-libc collation provider (ICU, builtin); values of more than about 14,653 labels (the changelog’s figure; any encoding) | Post-upgrade REINDEX INDEX CONCURRENTLY every ltree index. The documented symptom, label searches that silently miss rows with no error, was not reproduced as an effect of the upgrade (PG05): a GiST index missed rows for case-insensitive matches on the old image, the new image, after REINDEX and for a fresh index alike. The reindex advice stays on the PG04 evidence below. Confirm the changelog’s recommendation with the platform owner before repeating it. |
| Custom operator selectivity estimators | anyone with a user- or extension-provided oprrest / oprjoin on their own operators | Attaching a non-built-in estimator now needs superuser. Existing operators keep working; the check fires when one is re-created - pg_dump/pg_restore, a logical restore, or a branch - failing with must be superuser to specify a non-built-in restriction estimator function. Affects Path B’s schema restore and preview branches more than the in-place upgrade. Measured locally 2026-10-10 (PG02): as postgres the new image refuses CREATE OPERATOR and ALTER OPERATOR with a non-built-in RESTRICT or JOIN estimator (42501) and accepts eqsel; supabase_admin is accepted; postgres cannot create C functions. Operators created on the old image keep working. A pg_dump restored as postgres loses 2 of 3 operators, as supabase_admin it is clean. |
pgcrypto legacy ciphers | pgp_sym_encrypt data stored with cipher-algo bf, blowfish or cast5 | Before the upgrade, decrypt every stored value with a wrong passphrase: a value that decrypts is one of these ciphers. After it, decrypt with ignore-cipher-failure=1 and re-encrypt with cipher-algo=aes256. The old image stored these ciphers unencrypted, so a wrong key decrypted them; the new image fails to decrypt by default with encrypt error: Cipher cannot be initialized (PG01). aes128, aes256, 3des and the default are unaffected. |
btree_gist NaN indexes | GiST indexes on float4 / float8 columns (gist_float4_ops, gist_float8_ops) whose table can hold NaN | Post-upgrade REINDEX INDEX CONCURRENTLY each one. On the old image 5 of 10 predicates (float4) and 7 of 10 (float8) counted differently from a sequential scan, with x = 'NaN' returning 0 of 50 rows; a stale index on the new image still disagreed on 3 and 5; after the reindex, 0 (PG03). |
The queries that tell you whether the estimator and ltree caveats apply to
you are in the platform doc; run them before the window rather than reading the
caveat afterwards.1 The changelog carries detection queries for
all four of its entries.12
Local measurements for the 15.19 / 17.11 minor
Section titled “Local measurements for the 15.19 / 17.11 minor”The figures for the ltree, estimator, pgcrypto and btree_gist rows come from
a local Docker run on 2026-10-10 (PG01-PG05), not from the hosted upgrade
procedure. The public supabase/postgres image of the old minor built a fresh
data directory and a fixture and was stopped; the image of the new minor then
started on the same data directory - binaries replaced, data kept. The pairs
were 17.6.1.178 -> 17.11.0.004 and 15.14.1.178 -> 15.19.0.004, linux/arm64
on one Apple-silicon Mac. The old tags are the last builds of the old lines on
Docker Hub that day, not the build any hosted project ran, and the database
locale of a hosted project was not measured. The run was repeated three times;
of 508 measurement cells, run B differs from run A in 20 and run C in 19, all
index-layout noise. Figures below are run A. Evidence: the three runs are
published redacted under out/ and linked per module in Modules; the
pg-minor-17-11
RUNLOG
holds the per-cell record.
- pgcrypto (PG01, both pairs, 3 of 3 runs). On the old image
pgp_sym_encryptwithcipher-algobf, blowfish or cast5 left the sentence visible in the ciphertext bytes (compress-algo=0), and a wrong key decrypted it. On the new image the same bytes raiseencrypt error: Cipher cannot be initialized(error 39000) for the right key and the wrong key alike, and decrypt with either only whenignore-cipher-failure=1is passed; a fresh encrypt with those ciphers raises the same error. The old image rejects the option (Illegal argument to function), so it exists only after the upgrade. The wrong-passphrase scan flags exactlybf,blowfish,cast5on the old image, flags nothing on the new image by default (those values now fail like properly encrypted ones, with a different message), and flags the three again once the option is set. Decrypting with the option and re-encrypting withcipher-algo=aes256gave 3 rows that decrypt with the right key, refuse a wrong key and no longer show the sentence. Not measured:pgp_pub_encrypt, the_byteavariants, a hosted project. - Operator estimators (PG02, both pairs, 3 of 3 runs). The estimators were
ltreeparentselasRESTRICTand_int_overlap_joinselasJOIN, with a C-language wrapper function created bysupabase_admin. Aspostgresthe old image accepted all of them and the new image refused each with42501 must be superuser to specify a non-built-in restriction estimator function(the join wording forJOIN), forCREATE OPERATORand forALTER OPERATOR ... SET (RESTRICT = ...);eqselandeqjoinselwere accepted on both. Assupabase_adminall three creations succeeded on the new image.postgresgot42501 permission denied for language cwhen creating a C function on both images. The two operatorspostgrescreated on the old image were still present after the swap, and anEXPLAINand acount(*)over the restrict-estimator one succeeded.pg_dump -sfrom the new server held 3 operators; restored aspostgresinto a fresh database it gave 2 errors and 1 of 3 operators present, restored assupabase_admin0 errors and 3 of 3. Not measured: a hosted branch, a platform major-version upgrade, operators installed by extensions such as PostGIS. btree_gistNaN (PG03, both pairs, 3 of 3 runs). The fixture per type was 2000 ordinary values, 50 NaN and 5 Infinity, with a GiST index built on the old image and 10 predicates counted by sequential scan and by index scan. On the old imagex = 'NaN'andx >= 'NaN'counted 0 against a true 50, andx < 'NaN'counted 0 against 2005. On the new image the stale index countedx = 'NaN'0 of 50 and gotx < 'NaN'right; afterREINDEX INDEX CONCURRENTLYand for a fresh index every predicate matched the scan, for both types. The wrong-predicate counts of 10 were identical in all three runs:float45 on the old image, 3 stale, 0 reindexed, 0 fresh;float87, 5, 0, 0. The wrongness predates the upgrade, because the old image’s own index was already wrong, and the sequential scan is right at every stage. Counts for range predicates on a stale index vary with index layout between runs (float8x >= 1999counted 53, 37 and 45 against a true 57 in runs A, B and C on the 17 pair); only the zero and full-count cells are stable. amcheck has no GiST check on these images, so nothing here was amcheck-verified. Not measured: otherbtree_gistoperator classes, multicolumn keys, a hosted project.ltreelong values (PG04, both pairs, 3 of 3 runs).text2ltreeof n labels compared with the one-label'a'answered “not greater” first at n = 14655 on the old image (19 of 34 sweep values wrong; the sweep covered 14,640 to 14,670, 20,000, 40,000 and 65,535) and never on the new image. On a 453-row fixture of all-achains, a 3-label predicate counted 424 by sequential scan and 0 by a B-tree built on the old image, against a truth of 450, and that B-tree failsbt_index_parent_check(XX002 could not find tuple using search from root page). On the new image the stale index passedbt_index_checkandbt_index_parent_checkand answered every predicate correctly, which does not show a stale index is safe: either the fixture’s shape hides a violation or the tree happens to be ordered consistently with the corrected comparison, and the probe that would separate the two was not run.ltreecase folding (PG05, both pairs, 3 of 3 runs). The fixture was 300 words of 4 to 6 letters over ASCII and accented letters in both cases, 6 named probe rows and 20000 filler rows, with a GiSTltreeindex (siglen = 2000) built on the old image; each word was queried asp ~ 'WORD@'andp ~ 'word@'(600 queries per stage) in the default database (ICU on the 17 pair, libc on the 15 pair) and in a second libcen_US.UTF-8database. The index missed rows for 433 to 438 of 600 queries across the three runs (437 in run A), about 72 percent, on the old image, on the new image with the stale index, afterREINDEX INDEX CONCURRENTLYand for an index built from scratch on the new image, in all four database and pair combinations; it never returned extra rows (0 of 600). Not recorded in the artifact: a missing row is a stored word whose accented letters are in a different case from the query’s. Reading the upstream sources fetched the same day, the label-hashing functioncontrib/ltree/crc32.chas the same md5 prefix95b400b4atREL_15_14,REL_15_19,REL_17_6andREL_17_11, while the operator filelquery_op.cdiffers between the old and new tag in both lines. On libc databases the operator’s answer changed across the minor (U+0130followed bySTANBUL@matches 3 stored rows instead of 1, the index still returns 1); on the ICU database it did not. The PostgreSQL release notes for 17.1113 and 15.1914 list only an integer-overflow entry underltree, and the 18.2 notes15 describe an index-side fix that makes the index routines use the database’s default collation and requires reindexing. The reading that fits is that the index-side change the changelog describes is the 18.2 one and the two public images carry operator-side changes only; that is an inference from source and notes. Whether a build on the hosted platform differs from the public image was not tested. Not measured: a single-byte database, the builtin locale provider, major 18.
T-7 days
Section titled “T-7 days”- Announce the maintenance window to users (for small databases the real write-stop window is minutes, but budget for validation).
- Prune
cron.job_run_detailsif you usepg_cron(see the caveat table above) - the only caveat in the table that can fail the upgrade run. - If you use
pgcrypto, run the wrong-passphrase scan for bf / blowfish / cast5 values now: on the old image it flags them, and after the upgrade it flags nothing by default (caveat table above; PG01). - If
timescaledbis installed, convert every hypertable on 15 in the order under TimescaleDB, then drop the extension: eligibility lists it asunsupported_extensionuntil it is dropped, and the conversion guide as written failed on both table shapes tried (PX01). - Pick the window: your users’ quietest hours; avoid Friday/weekend.
- Run your own readiness review: enabled extensions vs the deprecated
list,
reg*data types referencing system OIDs, logical replication slots, custom roles with md5 passwords (pg_authid.rolpassword LIKE 'md5%'), unused indexes / bloat (smaller database = shorter window). The dashboard surfaces hard blockers on the upgrade screen itself.1
T-1 day
Section titled “T-1 day”- Drop deprecated extensions (for PG 17:
pgjwt,plcoffee,plls,plv8,timescaledb- convert hypertables first, see TimescaleDB; drop them from the dashboard’s database extensions page). - Delete read replicas (projects with replicas cannot be upgraded; you will recreate them after). Make sure the app tolerates reading from the primary in the meantime. This is for the in-place path only: a logical-replication move to 17 ran publication and copy with the source’s replica left in place, and on the target a replica added before its subscription served in 182 s while one added after a finished copy never served in 60 minutes (RR10, one run; Path B, Step 2).
- Take a fresh
pg_dumplogical backup - belt and braces on top of physical backups / PITR. - Prepare your write-stop (maintenance page, deploy freeze, queue pause - whatever stops writes cleanly).
In the window
Section titled “In the window”- Stop application writes - every writer: app services, queue workers,
and
pg_cronjobs (cron.alter_job(<jobid>, active := false)) - before pressing upgrade, and keep them stopped at least until the database answers on the new major, which in the 2026-11-09 runs came before ACTIVE_HEALTHY; writes acknowledged late in the window were lost (measured runs). - Settings > Infrastructure > Upgrade project -> target version. The dashboard’s estimate is the authoritative downtime figure.
- Watch it through; keep the rollback fact in mind (failure restores the original database).
Post-upgrade, same window
Section titled “Post-upgrade, same window”- Validate auth first (login + JWKS), then your heaviest write paths.
- Recreate read replicas -> they get new connection strings -> update app env.
- Reset passwords of any custom md5 roles to rehash as scram-sha-256.
- Re-enable pg_graphql introspection if any tooling needs it (probe with
{ __typename }, not{ __schema }; DD02), andREINDEX INDEX CONCURRENTLYanyltreeindexes (caveat table above). -
REINDEX INDEX CONCURRENTLYanybtree_gistindex on afloat4/float8column that can hold NaN, and decrypt-and-re-encrypt any bf / blowfish / cast5 values (caveat table above; PG03, PG01). - Check extension versions and the slow-query log for plan regressions.
- Re-enable writes.
Days after
Section titled “Days after”- Keep monitoring (advisors, slow queries, error rates) before declaring done.
- Delete the rehearsal clone - it bills at mirrored compute until you do.
Measured in-place upgrades (2026-11-09)
Section titled “Measured in-place upgrades (2026-11-09)”Three in-place upgrades from PostgreSQL 15.19 to 17.11 ran on 2026-11-09 with
pgmig’s in-place harness
(test/inplace-upgrade.harness.ts),
not a supabase-lab module; the two tabulated below completed the survival
check. The figures are copied from the run note
(docs/research/2026-11-09-pg15-to-17-live.md).
Each run created one throwaway project on a Team-plan org, Small compute,
ap-southeast-1, with postgres_engine: "15" on POST /v1/projects; seeded
pgmig’s test schema (50,000 or 4,000,000 rows in documents, which carries a
STORED tsvector column); read the eligibility endpoint; and sent
POST /v1/projects/{ref}/upgrade with target_version 17. The two tabulated
runs went to the image supabase-postgres-17.11.0.018, and eligibility answered
eligible: true, duration_estimate_hours: 1 at both sizes. The 3.65 GB
project had its disk grown to 20 GB before the seed (the SQLSTATE 25006 row
under What to do about it). From just before the POST
three loops ran; the writer and the sampler kept running until 180 s after the
project read ACTIVE_HEALTHY on 17, and the status loop stopped at that read:
- a writer inserted one numbered row into
public.upgrade_probeper fresh session-pooler connection, 1 s apart, and counted the id as acknowledged only when theINSERT ... RETURNINGcame back, recording theversion()andpg_postmaster_start_time()of the server that answered; - a sampler opened a fresh session-pooler connection every 2 s and read the same two values;
- the harness read
GET /v1/projects/{ref}/upgrade/statusevery 10 s, so a stage time is when it was first seen, to within 10 s. ACTIVE_HEALTHY below is the first of those checks at which the project read ACTIVE_HEALTHY and the latest sample had answered on 17.
Offsets are seconds on the harness clock, started immediately before the POST. After the settle the harness read back every acknowledged id.
| 0.06 GB (50,000 documents) | 3.65 GB (4,000,000 documents) | |
|---|---|---|
POST to 5_initiated_data_upgrade | +164 s | +153.5 s |
data upgrade (5_ to 6_completed_data_upgrade) | 122.5 s | 142.8 s |
POST to 9_completed_upgrade | +317 s | +337.1 s |
| POST to project ACTIVE_HEALTHY | 337.4 s | 633.1 s |
| first answer from 17.11 (sampler) | +318.8 s | +344.6 s |
| longest run of failed samples | +246.3 s to +256.3 s | +235.3 s to +270.4 s |
| probe writes acknowledged / absent on 17 | 458 / 53 | 691 / 52 |
| 15.19 postmaster starts the sampler saw | the original plus 2 restarts | the original plus 3 restarts |
| server that acknowledged the absent ones | the last 15.19 restart | the last 15.19 restart |
At 3.65 GB the first absent write was acknowledged at +272.9 s and 17.11 first
answered at +344.6 s. In neither run was a write acknowledged by the original
15.19 postmaster, an earlier restart or 17.11 absent. A first 3.65 GB attempt
the same day reached ACTIVE_HEALTHY at 695.5 s with a 142.9 s data-upgrade
stage; its survival check failed on a client-side getaddrinfo ENOTFOUND, so
it has no write count, and the harness now retries that read (the 0.06 GB run
used the harness before the retry was added).
The supabase-lab upgrade-integrity runs found the same loss on Micro on a Pro
org, 15.19 to the older target image supabase-postgres-17.11.0.003, four runs
on 2026-10-23 and 2026-10-26 (UI03, UI04;
RUNLOG):
run 1, which did not record the answering server, lost 15 of 106 acknowledged
writes, and in runs 2, 3 and 4 the 22, 88 and 88 lost writes were exactly those
acknowledged by the last restarted 15.19 postmaster before 17.11.
Reading the two runs (inference; one tabulated run per size; the sampler and the writer used the session pooler only):
- The data-upgrade stage barely moved with size, 122.5 s at 0.06 GB and 142.8 s at 3.65 GB, and the database answered on 17.11 at +318.8 s and +344.6 s.
- What grew is the tail between
9_completed_upgradeand ACTIVE_HEALTHY: 20.4 s at 0.06 GB, 296 s at 3.65 GB, with 17.11 already answering. That fits the upgrade guide’s last step, “When the upgrade succeeds, a pg_basebackup is taken and, once complete, your project is available in the Dashboard.”1 The extra 276 s for the extra 3.59 GB is about 77 s per GB, derived from two points; the guide’s “~100Mbps” read as 100 megabits a second gives 80 s per GB. Not separated: what the tail is, whether it stays linear past 3.65 GB, and whether the Data API or Auth answer during it. - Writes have to stop for the whole upgrade, from before the POST until the new major answers. The client-visible failures (10 s and 35.1 s of failed samples) are a small part of that window; at 3.65 GB the failed run ended at +270.4 s and the first write later found absent was acknowledged at +272.9 s.
Not measured: compute other than Small, regions other than ap-southeast-1, more than one completed run per size, databases larger than 3.65 GB, the Data API or a direct connection as write paths, and the dashboard button (the harness used the Management API).
Path B: cut over to a new PG 17 project with pgmig
Section titled “Path B: cut over to a new PG 17 project with pgmig”Pick this path when the in-place window is too long to stop writes for (17.11 first answered more than five minutes after the POST at both sizes measured on 2026-11-09, measured runs), or when the upgrade doubles as a region move. If a region move is the primary goal, the region-migration guide covers the region-specific repointing work (OAuth callbacks, custom-domain DNS, region-specific pooler hostnames) on top of this same pipeline. The target is a new project, so every row in the clone column of the carries-over table applies - new ref, new keys, new JWT secret (existing sessions invalidate), plus the Auth/Realtime/Edge-Function reconfiguration. The downtime window shrinks to the seconds it takes to drain replication lag, at the price of the full new-project reconfiguration.
How it works: native Postgres logical replication, orchestrated by pgmig. A publication + replication slot on the source, a subscription on the new PG 17 project; the subscription takes a consistent initial copy of your data tables, then streams WAL to stay caught up while the app keeps writing to the source. When you are ready: stop writes, prove the two databases are byte-identical with a chunked checksum, drain the last lag, resync sequences, repoint the app.16
Prerequisites: Bun (pgmig runs from source, no build step), psql /
pg_dump, the supabase CLI, and a personal access token
(SUPABASE_ACCESS_TOKEN) for project creation and the config copy.
Connectivity: direct vs pooler, and the IPv6 question
Section titled “Connectivity: direct vs pooler, and the IPv6 question”Logical replication needs a direct connection
(db.<ref>.supabase.co:5432); the pooler cannot stream WAL - a subscription
pointed at it fails at the tenant layer with could not connect to the publisher ... FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required) (edge-resilience W05,
supabase-lab). Direct hosts are
IPv6-only unless the project has the IPv4 add-on.17 Decide where
pgmig runs before anything else:
- IPv6-capable host (e.g. a small VM in the target region): point both URLs at the direct hosts. Simplest.
- IPv4 add-on on both projects for the migration window: same config, run from anywhere; remove it after.
- Split (works from a plain IPv4 laptop):
SOURCE_DB_URL/TARGET_DB_URLpoint at the IPv4 session pooler (used for dumps, admin, reconcile) andSOURCE_REPLICATION_URLpoints at the source direct host. The subscription connection is dialled by the target’s walreceiver over Supabase’s internal network, so your box never needs an IPv6 route. This is the configuration the measured run below used.
One more setting on that connection matters for any table whose initial copy
takes more than two minutes. On a Supabase source the postgres role is capped
by the default global statement_timeout of 2 min
(Supabase timeouts),
and the target’s tablesync worker, which runs each table’s initial COPY, dials
the same connection string, outside pgmig’s own pools. Without a fix the copy
is cancelled and starts again: 16 restarts at 4,000,000 rows on 2026-11-09, the table never synced.
pgmig now adds options=-c statement_timeout=0 to the subscription connection;
a hand-rolled CREATE SUBSCRIPTION or another tool needs the same option
(pgmig reference,
run note).
Step 0: rehearse on a throwaway pair
Section titled “Step 0: rehearse on a throwaway pair”bun start sandbox up --org <org-id> # creates + seeds a throwaway src/tgt pair# ... drive every step below against it ...bun start sandbox down # deletes both projects + generated filesThe sandbox seeds an awkward fixture on purpose (STORED tsvector generated
column, IDENTITY sequence, a no-PK table) and writes a ready-made
migrate.sandbox.yaml + .env.sandbox. Steps 1-7 below are exactly its
printed drive-through - run them against the sandbox once before touching
production config. Every drive-through command takes the sandbox config + env
files, e.g. bun start -c migrate.sandbox.yaml --env-file .env.sandbox doctor.
The pair bills until sandbox down deletes it.
e.g. bun start sandbox up --org <your-org-id> provisions
pgmig-sandbox-src (eu-central-1) + pgmig-sandbox-tgt (eu-west-1) -
the measured run below was provisioned exactly this way, in ~3 minutes,
under the tool’s earlier name (sbshift-sandbox-src /
sbshift-sandbox-tgt).
Step 1: stage config + env
Section titled “Step 1: stage config + env”migrate.config.yaml: source/target refs, the enumerated table list
(never FOR ALL TABLES - it needs superuser), publication/slot/subscription
names, the reconcile table list, and the WAL watchdog threshold
(watchdog.maxRetainedWalMb). .env: the connection strings +
SUPABASE_ACCESS_TOKEN.
Step 2: create the target project
Section titled “Step 2: create the target project”supabase projects create <name> --org-id <org> --region <target-region> \ --db-password "$(openssl rand -base64 24)"New projects land on the current platform default major (17 as of 2026-07),
which is what makes this path an upgrade path. Put the new ref in the config
and its pooler/direct strings in .env. e.g. for a PG 15 production in
eu-central-1 moving to eu-west-1:
supabase projects create my-app-pg17 \ --org-id <your-org-id> --region eu-west-1 \ --db-password "$(openssl rand -base64 24)"Read replicas can stay on the source for this path: the docs list deleting
them as a prerequisite of the in-place upgrade,1 and in RR10
(2026-11-10, one run: Team org, Small, pitr_7, 24 GB disks, a 15.19 source
with a 3.9 GiB table, 17.11 targets) the source’s replica was left in place
while the publication and both slots worked and both copies delivered
4,000,000 rows (one target’s table never reached r, for the reason under
Step 5). If the
new project needs a replica, add it while the project is empty, before
replicate: a replica added before its subscription accepted a first session
after 182 s and followed the copy, with lag up to 81,396,272 bytes, while one
added about 38 minutes after a finished copy got no pooler entry and never
served in 60 minutes. Why the late one stalled was not read from outside. Both
replicas that followed the 3.9 GiB write, the source’s and the early target’s,
logged No space left on device while the primaries had 24 GB disks; the
source replica’s rows were not counted
(RR10 RUNLOG).
Step 3: restore what replication does not carry
Section titled “Step 3: restore what replication does not carry”Logical replication moves table rows only - no DDL, roles, sequences,
extensions, or the managed auth/storage schemas:
bun start bootstrap --with-auth-data --confirmbootstrap enables non-default extensions and restores roles + schema onto
the target in one pass; --with-auth-data also loads the auth-schema rows
(with triggers deferred via session_replication_role = replica). The auth
part is required when any replicated table has an FK into
auth.users - the initial copy is FK-rejected row by row otherwise, and
doctor flags that cross-schema FK explicitly. Manual fallback: supabase db dump for roles/schema/auth + a single-transaction psql restore -
excluding auth.schema_migrations from the auth data dump (it is SELECT-only
for the postgres role on managed targets; the restore fails on it otherwise).
A PG 17 target adds one schema-restore failure mode: an operator carrying a
non-built-in selectivity estimator cannot be re-created without superuser, so
the restore dies on must be superuser to specify a non-built-in restriction estimator function.1 Most projects have no such operator; the
platform doc carries the pg_operator query that tells you whether yours
does. In the local run (PG02, a Docker data-directory swap, not a hosted
restore) a dump holding three operators restored as postgres with 2 errors and
1 of 3 operators present, and as supabase_admin with 0 errors and 3 of 3.
Step 4: the gates - doctor + preflight
Section titled “Step 4: the gates - doctor + preflight”bun start doctor # fail-closed readiness audit of BOTH endsbun start preflight # hard gate: wal_level, grants, replica identityDo not proceed past a NOT READY. In the measured run doctor exited 1
with exactly the 5 missing target tables before bootstrap, and reported
READY (with warnings) - 29 pass / 4 warn / 0 fail - after it.
Step 5: replicate + watch
Section titled “Step 5: replicate + watch”bun start replicate # publication + slot + subscription; initial copy startsbun start watch # polls until every table is srsubstate='r'The app keeps writing to the source throughout. watch aborts on its own if the slot bloats source WAL past the
watchdog threshold - an unconsumed slot retains WAL until the source disk
fills - or the slot’s wal_status flips to lost.
Freeze schema deploys on the source while the subscription runs. In the lab a
source-only ALTER TABLE stalled every table’s stream - zero rows arrived on
the target, including rows that did not touch the new column - and applying
the same ALTER on the target resumed replication in about 6.1 s with the
missed rows backfilled and no subscription recreation (edge-resilience W15,
2026-08-16). If a migration must ship during the window, apply the DDL on the
target first, then on the source.
When several new targets subscribe to one source, subscribe them one at a
time. Postgres names each
table-sync slot on the source pg_<subscription oid>_sync_<table oid>_<system identifier>,
and new 17 projects often share all three: 24 of 26 new 17.11 projects read in
RR10 and RR11 reported one system_identifier and the other 2 shared a second
one (one region and one org; one project’s were not recorded), and the same
setup steps gave 10 of 16 subscribed targets the same subscription and table
OIDs. In 3 of 3 concurrent pairs with matching names, one target’s table was
still in f at the end of its wait bound (40 minutes in RR10, 10 in RR11),
with a row count equal to the source’s. In RR10 and RR11 run 3 that target
still missed rows written afterwards; in RR11 run 4 it recovered, and the last
target subscribed with the same names, started while an earlier one was stuck,
missed them instead. Start the next subscription only after every table of the
previous one is r in pg_subscription_rel, and confirm each target with a
marker row written on the source after the copy, since a stuck target’s count
matched. That one at a time avoids the collision rests on the Postgres code,
which drops a table-sync slot when its table reaches sync-done, and on one
incidental RR11 run-2 case; RR11’s reading of its run-4 states is that it
protects only while no earlier target with the same names is stuck. Details are in the pgmig
reference; the runs are in the
RR11 RUNLOG.
Step 6: cutover (the only downtime)
Section titled “Step 6: cutover (the only downtime)”# 1. STOP application writes to the source (read-only / maintenance page).bun start reconcile # must print RECONCILE PASSEDbun start cutover # drains lag to 0, resyncs sequences, drops subscription# 2. Repoint the app at the new project (URL + keys). Never re-enable# writes on the source.reconcile chunked-checksums every replicated table on both ends.
cutover samples the source WAL LSN twice and warns loudly if it is still
advancing (writes not stopped), waits for lag to reach zero, then
setval()s every sequence owned by a replicated column - sequences do not
replicate, and the schema restore only carried their dump-time values, so
rows inserted after bootstrap would otherwise collide on the next
serial/IDENTITY insert.
Decide the rollback before the write-stop, because it changes at the repoint
(pgmig docs/RUNBOOK.md, sections 9 and 12 - a procedure, not a
measurement). Create a named restore point on the source via the Management
API before stopping writes. Up to the moment the app is repointed, rollback is
lossless: bun start teardown, re-enable writes on the source, bring the app
back unchanged - the target has taken no application writes. After the
repoint nothing replicates target -> source, so the options are to roll
forward on the target, to repoint back and re-apply the loss window by hand
(never with writes enabled on both), or - if you set it up between
reconcile passing and the repoint - to drain reverse replication and cut
back. Reverse replication is a second config with the roles swapped,
distinct slot / publication / subscription names and copyData: false, since
the data already matches: bun start -c migrate.reverse.yaml replicate. It
is one direction at a time, never active-active, and W05 measured
managed -> managed streaming in one direction only.
Step 7: copy non-data config, verify, tear down
Section titled “Step 7: copy non-data config, verify, tear down”bun start config-sync --dry-run # review the diff firstbun start config-sync # Auth/Realtime/PostgREST/Storage/pooler settingsbun start provision # preview matching billable infra (compute size!)bun start verify # Supabase advisors on the target, as a health gatebun start teardown # drop subscription -> slot -> publicationSecrets are stripped by default - re-enter SMTP/OAuth credentials on the target. The JWT signing secret and API keys are never copied (they are not on any synced endpoint), so users re-login after cutover. Leave the old project paused, not deleted, for a few days as a safety net.
Storage and Edge Functions, if you have them, transfer separately here:
bun start storage <localDir> for object bytes (buckets do not arrive with
the schema restore, and the push re-creates them private - restore
visibility) and supabase functions deploy --project-ref <new-ref>. The
region-migration guide details both
transfers plus the wider repointing checklist (OAuth callbacks, custom
domains) that a new project on this path needs too.
Two things the schema restore deliberately leaves behind, to re-apply by
hand after cutover: cron.schedule(...) job rows (job schedules are data,
not DDL - the target will not fire your pg_cron jobs until you re-add them,
which also means no double-firing while both projects are live), and any
ALTER ROLE ... SET / ALTER DATABASE ... SET GUC overrides, which live in
pg_db_role_setting and are invisible to the Management API endpoints
config-sync reads (doctor diffs them and warns).
The same pipeline by hand
Section titled “The same pipeline by hand”Everything pgmig automates above is plain Postgres + Management API calls. If you cannot (or do not want to) run the tooling, the manual equivalent of steps 3-6:
# schema + roles + auth users (steps 3's manual fallback, in full)supabase db dump --db-url "$SRC" -f roles.sql --role-onlysupabase db dump --db-url "$SRC" -f schema.sqlsupabase db dump --db-url "$SRC" -f auth.sql --data-only --schema auth --use-copy \ -x auth.schema_migrations # SELECT-only for postgres on managed targetspsql -d "$TGT" -f roles.sql # errors on pre-existing roles are expectedpsql --single-transaction -v ON_ERROR_STOP=1 -d "$TGT" -f schema.sqlpsql --single-transaction -v ON_ERROR_STOP=1 -d "$TGT" \ -c 'SET session_replication_role = replica' -f auth.sql-- source: publication over the tables to move (enumerate; FOR ALL TABLES-- needs superuser)create publication upgrade_move for table public.t1, public.t2;
-- target: subscription (creates its slot on the source, takes a consistent-- initial copy, then streams WAL)create subscription upgrade_move_sub connection 'host=db.<src-ref>.supabase.co port=5432 dbname=postgres user=postgres password=<pw> sslmode=require' publication upgrade_move with (slot_name = 'upgrade_move_slot', copy_data = true);
-- target: watch until every table is ready (i -> d -> s -> r)select c.relname, r.srsubstatefrom pg_subscription_rel rjoin pg_subscription s on s.oid = r.srsubidjoin pg_class c on c.oid = r.srrelid;
-- cutover: STOP WRITES, then confirm the lag has drained on the sourceselect application_name, write_lag, flush_lag, replay_lagfrom pg_stat_replication;
-- target: resync every owned sequence (sequence VALUES do not replicate)select setval('public.items_id_seq', (select max(id) from public.items));
-- teardowndrop subscription upgrade_move_sub; -- on the targetdrop publication upgrade_move; -- on the sourceselect pg_drop_replication_slot('upgrade_move_slot'); -- on the source, if the slot remainsBy hand you lose the gates (readiness audit, wal_level/grant/
replica-identity preflight), the WAL-bloat watchdog while the subscription
is live, the chunked-checksum reconcile (a manual count(*) per table is
not a proof of identical data), the quiescence check, and the config copy -
transcribe the settings pages or script the Management API endpoints from
the three-ways matrix. If you can take the full
copy time as downtime instead, plain dump/restore to a new PG 17 project
skips the replication machinery entirely - the region guide’s Variant
A
writes it out; the reconfiguration burden is identical.
Measured run (2026-07-30)
Section titled “Measured run (2026-07-30)”Full pipeline against a throwaway cross-region pair (eu-central-1 -> eu-west-1, driven from a non-IPv6 box via the pooler + replication-URL split; projects deleted after):
| Step | Observed |
|---|---|
sandbox up | pair ACTIVE_HEALTHY in ~3 min; seeded 3,000 documents (~2 KB each) + 300 IDENTITY items |
doctor (pre-bootstrap) | exit 1: 24 pass / 4 warn / 5 fail - the 5 fails were exactly the missing target tables |
bootstrap --confirm | extensions + roles + schema restored in one pass |
doctor (post-bootstrap) | READY (with warnings): 29 pass / 4 warn / 0 fail (warnings: subscriber worker-count GUCs, fine at this size) |
replicate + watch | publication + slot + subscription created; 5/5 tables synced in under 5s at this size |
reconcile | RECONCILE PASSED - source == target row counts and hashes on all tables |
cutover | WAL-quiescent check passed, lag 0.0 KB, sequence public.items_id_seq set to 300, subscription dropped |
| post-cutover insert | insert into items ... returning id -> 301, no PK collision |
config-sync --dry-run | per-section diffs (Realtime, Database Pooler, PostgREST, Storage); secrets stripped |
verify | advisor gate fired correctly (rls_disabled_in_public on the intentionally RLS-less sandbox fixture) |
| total wall time | under 15 minutes including project provisioning and sandbox down |
At larger sizes, a 1,000,000-row initial sync completed
in 22.7s (12.5s on a second run) with ~245-276ms streaming lag afterward,
measured in supabase-lab
(edge-resilience W22, 2026-08-16). Platform-managed schemas (auth.*,
storage.*) stream zero changes at
any tested size (W09, and the W14 manual drill recorded only in the edge-resilience RUNLOG); public and custom tables move fine.
A second pass the same day seeded the repointing surface (pg_cron job, public
bucket, auth user, project secret, custom role, config change) and exercised
the config-sync apply path live; results are tabulated in the
region-migration guide’s measured
run.
3,000 small rows copy in seconds. At real sizes the initial copy takes
longest, and a STORED generated column measured as the throughput
bottleneck (~7x slower copy, ~11 MiB/s vs ~80 MiB/s in pgmig’s
scale rehearsal) - watch shows live per-table copy %, so calibrate your
window from that, and set maxRetainedWalMb generous enough to hold a full
copy’s worth of WAL on the source.
What to do about it
Section titled “What to do about it”Module ids are edge-resilience drills, platform-facts probes and the
compute-disk, data-api-defaults, pg-minor-17-11, pg17-extensions,
replica-routing, restore-paths, storage-surface and upgrade-integrity modules
in
supabase-lab; “RUNBOOK” is
pgmig’s docs/RUNBOOK.md, a procedure rather than a measurement; “pgmig
in-place harness” is the 2026-11-09 runs under Measured in-place
upgrades.
Before the window
- Read
duration_estimate_hoursfrom the upgrade eligibility endpoint and publish that as the budget: three aged projects eligible for17.6.1.141 -> 17.6.1.155each reported1, and one project answeredeligible: nullwith no version fields, so treat null as “not computable” rather than false (platform-facts F06, 2026-08-04). A sweep of the four lab projects on 2026-10-13 found no null (F07a: 3 true, 1 false), so what produces null is still unexplained. - Time the in-place window on a project created on the old major: a project
created with the defaults comes up at the latest version (
eligible: false,target_upgrade_versions: []), andpostgres_engine/release_channelonPOST /v1/projectsare deprecated and typednull(F06, 2026-08-04), but a create withpostgres_engine: "15"came up on PostgreSQL 15.19, eligible for 17, on a Pro org on 2026-10-23 (UI01) and on a Team-plan org on 2026-11-09 (pgmig in-place harness). The clone is still the only rehearsal on your own data and extensions. - Budget the PITR prerequisite as its own step: PITR is refused below Small compute, the Micro -> Small resize took REST reads down for 231.465 s, with Auth and Realtime joins within 4 s of it, and the step back took REST reads down for 254.886 s (Realtime joins 244.941 s) (compute-disk D09, 2026-10-23), and the addon endpoint rate-limits consecutive changes, so the compute change and the PITR change go in separate windows.
- Create a named restore point on the source via the Management API before stopping writes (RUNBOOK section 9).
- Run the pgcrypto wrong-passphrase scan before the in-place upgrade to a 15.19 / 17.11 build: bf, blowfish and cast5 values were stored unencrypted on the old image, the scan flags them there and flags nothing on the new image by default (PG01, local Docker, 2026-10-10).
- Compare the bucket’s
storage.objects.namevalues with the S3 endpoint’s accepted key classes before anaws s3 sync: 22 of 40 keys tried were refused on put (SS02, 2026-10-10).
Before either path: TimescaleDB hypertables and read replicas
| Practice | Evidence | Rests on |
|---|---|---|
| Convert every hypertable to native partitioning on 15 before either path | With timescaledb installed, eligibility answered eligible false with validation_errors [{"type":"unsupported_extension","extension_name":"timescaledb"}], and after the drop eligible true with []. A publication on a hypertable listed 32 tables, 31 of them chunks in _timescaledb_internal, and the subscription on 17.11 failed with 3F000 schema "_timescaledb_internal" does not exist, 0 rows copied. The converted table, published with publish_via_partition_root = true, had every table r at the first 10 s check with 300,202 rows on both, and later rows in a premade and the default partition arrived. One run; an in-place upgrade after the conversion was not run. | PX01d, PX01e, PX01h, PX01i (2026-11-10) |
Run create_parent before the copy; narrow including all if there is a primary key | The pg_partman guide as written failed on both shapes: 42P16 multiple primary keys for table "messages" are not allowed on the hypertable with primary key (id, sent_at), and 23514 no partition of relation "events" found for row on the copy into the one without. With create_parent first, and including defaults including constraints including identity including generated for the table with a primary key, 300,000 and 300,200 rows copied (2178 ms and 1294 ms, one sample each). | PX01f, PX01g (2026-11-10) |
After an identity copy with overriding system value, setval the sequence to max(id) | A plain insert ... select * into the GENERATED ALWAYS column failed with 428C9; with overriding system value it copied. Without the setval the next insert got id 1 while max(id) was 300200, 2 rows then had id 1, and the primary key (sent_at, id) raised no error; after it the next insert got 300201. | PX01g (2026-11-10) |
| On the logical path, keep the source’s read replica | With the 15.19 source’s replica left in place, the publication and both slots worked and both copies of the 3.9 GiB table delivered 4,000,000 rows; the docs list deleting replicas as a prerequisite of the in-place upgrade. One run (Team org, Small, pitr_7, 24 GB disks). The source’s replica logged No space left on device at 09:29:54 UTC, before the subscriptions (hand read), and its rows were not counted. | RR10 (2026-11-10) |
Add the target’s read replica to the empty project before replicate | Added before the subscription, the replica accepted a first session after 182 s and followed the copy (lag up to 81,396,272 bytes). Added about 38 minutes after a finished copy, a replica got no pooler entry in 60 minutes and never served; why was not read from outside. One run. | RR10 (2026-11-10) |
| Subscribe several targets from one source one at a time, each confirmed by a marker row | 24 of 26 new 17.11 projects (one region and org where recorded) reported one system_identifier, and 10 of 16 subscribed targets had the same subscription and table OIDs, so their table-sync slot names matched. In 3 of 3 concurrent pairs with matching names one target’s table was still in f at the end of its wait bound (40 minutes in RR10, 10 in RR11) with a row count equal to the source’s; in RR10 and RR11 run 3 that target missed later rows, and in RR11 run 4 it recovered while the last same-named target, started while an earlier one was stuck, missed them. That one at a time avoids the collision rests on the Postgres code (the sync slot is dropped at sync-done) and one incidental RR11 run-2 case. | RR10, RR11 (2026-11-10) |
In the in-place window
| Practice | Evidence | Rests on |
|---|---|---|
Stop every writer (app services, pg_cron jobs, queue workers) before pressing upgrade | Writes acknowledged late in the window were absent on 17.11 in both 2026-11-09 runs whose survival check completed (53 of 458 at 0.06 GB, 52 of 691 at 3.65 GB; a third run lost its check to a client-side getaddrinfo ENOTFOUND) and in all 4 lab runs on Micro (15, 22, 88 and 88 writes). Every absent write in the 2026-11-09 runs and in lab runs 2 to 4 was acknowledged by the last 15.19 postmaster restart before 17.11 answered; at 3.65 GB the first at +272.9 s. The runs measured client inserts only; that pg_cron writes on that postmaster go the same way is inference. | pgmig in-place harness, 2026-11-09; UI03, UI04 (2026-10-23, 2026-10-26) |
Judge the write-stop window by the first version() answer on the new major | 17.11 first answered the session pooler at +318.8 s (0.06 GB) and +344.6 s (3.65 GB); the project read ACTIVE_HEALTHY at 337.4 s and 633.1 s. The tail after 9_completed_upgrade grew from 20.4 s to 296 s, about 77 s per GB derived from two points with one run each, so expect it to grow with size (inference). The Data API and Auth during the tail were not measured: the sampler used the session pooler only. | pgmig in-place harness, 2026-11-09 |
| Grow the disk before seeding a test project with gigabytes of data | The first 4,000,000-document seed on the default disk failed after about 6 minutes with cannot execute INSERT in a read-only transaction (SQLSTATE 25006), the platform making the database read-only as the volume filled. The 3.65 GB runs grew the disk to 20 GB first (DISK_GB, test/disk.ts). | pgmig live harness (test/live.harness.ts), 2026-11-09 |
After the in-place upgrade to 15.19 / 17.11
- Reindex
btree_gistfloat NaN indexes withREINDEX INDEX CONCURRENTLY: a stale index still disagreed with a sequential scan on 3 of 10 predicates (float4) and 5 of 10 (float8) on the new image (PG03). - Keep the
ltreereindex, and confirm the changelog’s case-folding rationale with the platform owner before repeating it: PG05 did not reproduce the symptom, while PG04 supports the reindex for values over about 14,653 labels. - Probe pg_graphql with
{ __typename }and read the body; the HTTP status is 200 in the absent, enabled and refused-introspection states (DD02).
While the subscription runs (Path B)
- Freeze DDL on the source, or apply each migration on the target first: a
source-only
ALTERstalled every table’s stream, and the sameALTERon the target resumed it in about 6.1 s with backfill (W15). - Point the subscription at the direct host only; the pooler refuses with
FATAL: (ENOIDENTIFIER) no tenant identifier provided (external_id or sni_hostname required)(W05). - When scripting the by-hand path through the Management API query endpoint,
send
CREATE SUBSCRIPTIONas its own single-statement request; the endpoint wraps a multi-statement string in one transaction and Postgres refusesCREATE SUBSCRIPTIONinside one (W05). - If a table sticks in
srsubstate = 'd'withpidnull inpg_stat_subscription(seen only onauth.*andstorage.*, which do not replicate managed -> managed; W09, W14), recover in this order:ALTER SUBSCRIPTION ... DISABLE,ALTER SUBSCRIPTION ... SET (slot_name = NONE),DROP SUBSCRIPTION, thenpg_drop_replication_sloton the source -slot_name = NONEplus drop leaves the publisher slot behind, pinning WAL (W09, W14).
Cutover and rollback
- Decide the rollback before the repoint: before it,
teardownplus re-enabled source writes is lossless; after it, roll forward, accept the loss window, or have reverse replication (copyData: false, roles swapped) running from betweenreconcileand the repoint (RUNBOOK section 12; W05 measured one direction only). - Re-password every custom LOGIN role on the target
(
ALTER ROLE <name> WITH PASSWORD '...') before any service that uses it is repointed; the role arrives withrolpasswordNULL (the region guide’s measured run; RUNBOOK sections 0 and 9).
After cutover
- After
config-sync, poll the target’s config readback until it matches instead of reading once - the apply is asynchronous: in the W17 drill a readback straight after its restore PATCH returned the pre-restore value (edge-resilience battery 2026-08-17) - and diff auth defaults between the two projects:custom_oauth_max_providersdefaulted to 32767 on one project generation and 3 on another. - The paused-window length (“a few days”),
watchdog.maxRetainedWalMb, whether to match compute withprovision, and when to schedule the window are design choices; no run measured them.
Verification
Section titled “Verification”| Check | How | Expected |
|---|---|---|
| Clone is a faithful data copy | compare row counts / spot-check marker rows | identical |
| Clone storage metadata | list buckets + objects via API | all present |
| Clone storage bytes | GET a pre-existing object via clone ref | 404 (expected) |
| Clone upload path | PUT then GET a new object | 200 / 200 |
| Clone config gaps | Settings > API, Auth > SMTP | defaults; re-entered values stick |
| Clone upgrade pre-flight | upgrade screen blocker list | only known blockers (e.g. pgjwt) |
| Prod post-upgrade | show server_version via psql | target version |
| Prod identity | API URL, keys, JWT secret | unchanged |
| Replica recreated | app env holds new replica string | reads flowing |
| Replication caught up (pgmig path) | pgmig watch (or status --require-synced) | every table srsubstate='r' |
| Data identical pre-cutover | pgmig reconcile | RECONCILE PASSED |
| Sequence resync | post-cutover insert ... returning id on a serial/IDENTITY table | next value, no PK collision |
| Target health gate | pgmig verify | no advisor lints at/above your --fail-on level |
Gotchas and lessons learned
Section titled “Gotchas and lessons learned”- Supabase’s clone doc contradicts itself on extensions, and only one reading is
safe. It lists “Database extensions and settings” under what needs manual
reconfiguration, and then states that because the entire database is copied the
clone includes every extension enabled at the source - with a warning to disable
pg_net,pg_cronandwrappersafterwards.2 The second reading matches what we measured. Someone who trusted the first list would expect to re-enable extensions by hand and would never go looking for a live cron job on the clone that is already firing at production endpoints. - Do not confuse the two flows. Clone = new project + reconfiguration. In-place upgrade = same project, no reconfiguration. Nearly every “upgrade checklist” mistake is applying one flow’s steps to the other.
- A clone’s dashboard lists storage objects whose bytes are missing. Test a GET, not the listing.
pg_cronon clones is a production hazard. Jobs copy active and will double-fire (emails, webhooks, billing jobs) until unscheduled.- Schema exposure and SMTP are the two forgotten reconfigurations -
both fail quietly: nothing flags them at setup, then the API answers
406 PGRST106on your custom schema, and auth emails fall back to the rate-limited built-in sender. - Disk only grows outside an upgrade - and shrinks during one. You can increase disk size but never decrease it by hand or via auto-resize.11 The upgrade is the documented exception: it right-sizes the disk to ~1.2x the current database size, so a 100 GB database on a 200 GB disk comes back on 120 GB.1 On gp3 the IOPS you can provision scales with disk size (500 extra IOPS per GB), so a right-sized disk also lowers that ceiling.11
- The clone mirrors compute at clone time. If you resized production after your last clone, your next clone lands on the new size and bills accordingly.
- The upgrade keeps your compute size. It is a version change, not a resize.
- The same in-place process covers minor and future major versions (e.g. PG 18 when it becomes available as a target).1
- Restore-to-new-project is dashboard-only - there is no Management API or CLI path for it as of 2026-07 (the API only restores in place). Re-verify before scripting around it.
- Sequences do not replicate (pgmig path). The schema restore carries
their dump-time values, so every row inserted on the source between
bootstrap and cutover would collide on the next serial/IDENTITY insert
without a resync -
cutoversetval()s every owned sequence (verified: id 301 after 300 seeded rows). - pg_cron does not double-fire on the pgmig path (unlike the clone
path):
cron.schedule(...)rows are data, not DDL, so they are absent on the target until you re-add them after cutover. The risk is forgetting to re-add them. - A STORED generated column is the copy bottleneck - measured ~7x slower
initial copy (~11 MiB/s vs ~80 MiB/s in pgmig’s scale rehearsal).
watchshows live per-table copy %; calibrate your window from that, not from row counts. config-syncis blind topg_db_role_setting.ALTER ROLE ... SET/ALTER DATABASE ... SEToverrides (statement_timeout,auto_explain.*, …) are not on the Management API endpoints it reads.doctordiffs them between source and target and warns; re-apply by hand.
File reference
Section titled “File reference”| File | Where it is used |
|---|---|
migrate.config.yaml | pgmig config: source/target refs, the enumerated table lists, publication/slot/subscription names, watchdog.maxRetainedWalMb (Step 1) |
.env | connection strings + SUPABASE_ACCESS_TOKEN (Step 1) |
roles.sql | manual fallback: roles-only dump, restored first (pre-existing-role errors expected) |
schema.sql | manual fallback: schema-only dump, single-transaction restore |
auth.sql | manual fallback: auth-schema data dump excluding auth.schema_migrations, restored with session_replication_role = replica |
supabase/seed.sql | preview-branch seed: supabase db dump --data-only --linked > supabase/seed.sql; branches run it once at creation |
Modules
Section titled “Modules”References
Section titled “References”-
Supabase, “Upgrading,” Supabase Docs. https://supabase.com/docs/guides/platform/upgrading ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11
-
Supabase, “Restore to a new project,” Supabase Docs. https://supabase.com/docs/guides/platform/clone-project ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10
-
Supabase, “Restore Dashboard backup - Migrate storage objects,” Supabase Docs. https://supabase.com/docs/guides/platform/migrating-within-supabase/dashboard-restore ↩
-
Supabase, “S3 Authentication,” Supabase Docs. https://supabase.com/docs/guides/storage/s3/authentication ↩
-
Supabase, “Error Codes,” Supabase Docs. https://supabase.com/docs/guides/storage/debugging/error-codes ↩
-
Supabase, “Using Custom Schemas,” Supabase Docs. https://supabase.com/docs/guides/api/using-custom-schemas ↩
-
Supabase, “timescaledb: Time-Series data,” Supabase Docs. https://supabase.com/docs/guides/database/extensions/timescaledb ↩ ↩2
-
Supabase, “Migrate from TimescaleDB to pg_partman,” Supabase Docs. https://supabase.com/docs/guides/database/migrating-to-pg-partman ↩
-
Supabase, “CLI workflows,” Supabase Docs. https://supabase.com/docs/guides/local-development/cli-workflows ↩
-
Supabase, “Working with branches - Seeding behavior,” Supabase Docs. https://supabase.com/docs/guides/deployment/branching/working-with-branches ↩
-
Supabase, “Compute and Disk,” Supabase Docs. https://supabase.com/docs/guides/platform/compute-and-disk ↩ ↩2 ↩3
-
Supabase, “PostgreSQL 15.19 / 17.11 minor release - action may be required for ltree, pgcrypto, btree_gist, and custom operators,” Supabase Changelog, Sep. 25, 2026. https://supabase.com/changelog/postgres-15-19-17-11-breaking-changes ↩ ↩2
-
PostgreSQL Global Development Group, “E.1. Release 17.11,” PostgreSQL 17 Documentation. https://www.postgresql.org/docs/17/release-17-11.html ↩
-
PostgreSQL Global Development Group, “E.1. Release 15.19,” PostgreSQL 15 Documentation. https://www.postgresql.org/docs/15/release-15-19.html ↩
-
PostgreSQL Global Development Group, “E.4. Release 18.2,” PostgreSQL 18 Documentation. https://www.postgresql.org/docs/current/release-18-2.html ↩
-
pgmig, “Postgres-to-Postgres logical-replication migrator,” GitHub. https://github.com/erfianugrah/pgmig ↩
-
Supabase, “IPv4 Address,” Supabase Docs. https://supabase.com/docs/guides/platform/ipv4-address ↩
Linked from
- Migrate a Supabase project to another region, end to end
- Migrating a static MongoDB archive into Postgres with the Supabase MongoDB wrapper
- pg_cron on Supabase: restarts, resizes, COMMIT in a job and run history, measured
- pgmig: what a logical-replication move carries, and the gates around it
- Supabase disaster recovery tiers: daily backups, PITR, warm standby - RPO, RTO, and cost
- Supabase read replicas: how requests reach them and what they cost
- Supabase Storage surface: direct SQL deletes, list pagination, S3 key handling