All articles
Operations··10 min read

You can undo the deploy. You cannot undo the migration.

Rolling back code on Vercel is instant and free on every plan. Supabase has no down migration at all. That asymmetry should decide where you spend your caution, and it is the opposite of how most deployment advice is written.

Rolling back a bad deploy on Vercel takes seconds, works on every plan including the free one, and is described in the documentation as instantaneous. There is no equivalent for your database.

That asymmetry should decide where you spend your caution. Shipping code is cheap to undo, so ship often and stop agonising over it. Changing a table is not undoable at all on this stack, so that is the thing to slow down for. Most advice about deployment safety has the emphasis backwards for a small app.

What instant rollback actually does

It reverts the code. That is genuinely valuable and genuinely instant. But read the caveats in Vercel's own documentation, because each one is a way to roll back and still be broken:

  • Environment variables do not revert. If you changed one in project settings, the rolled back build gets the new value.
  • Cron jobs revert to the old deployment's state, which may not be what you expect.
  • Automatic production domain assignment is switched off afterwards. New pushes to your production branch stop replacing the rolled back deployment until you turn it back on. People lose an hour to this wondering why their fix is not going live.
  • Your database does not move. Vercel lists this as a reminder about external APIs and databases. It is the whole problem.

So the deploy is reversible and the schema change that shipped with it is not. Which brings us to the part worth being careful about.

Supabase does not have down migrations

This surprises people coming from Rails or Django, where every migration has an inverse. On Supabase the inverse does not exist, and the documentation never quite says so in one sentence, so it is worth showing the pieces.

supabase migration down is not an inverse. It is documented as resetting applied migrations up to the last n versions, and its own confirmation prompt warns that you will lose all data in the database. It drops and replays rather than stepping backwards.

supabase migration repair updates the tracking table only. It does not apply or revert any SQL. It fixes bookkeeping, not schema.

The Management API endpoint that sounds like a rollback removes rows from the migration history table, not changes from your schema.

And when the documentation addresses rolling back directly, in the branching troubleshooting guide, the answer is to delete the preview branch and reopen it, with the note that any data changes on the old branch are lost.

So the only production rollback on Supabase is a second migration that undoes the first one. Write that before you push anything risky, while you still remember what the previous state was.

To be precise about sourcing: there is no Supabase sentence that says “down migrations are not supported.” That conclusion comes from four separate documented behaviours pointing the same way, plus the fact that the docs prescribe a different remedy when asked the question. If you find an official contradiction, trust it over me.

The golden rule, which the docs state in bold

The golden rule: never change the remote database directly. Once you're using migrations, all schema changes, even small ones, should go through migration files. Using the Dashboard's SQL editor or Table Editor on your remote database bypasses the migration history, and db push will start failing with sync errors.

· Supabase documentation, Database Migrations

This is the most commonly broken rule on the platform, because the dashboard is right there and adding a column takes four seconds. The cost arrives later, when local and production have quietly diverged and your next deploy fails. The documented recovery is supabase migration list to see the divergence, then supabase db pull to capture the current remote schema into a new migration file, then commit it.

The migration that takes your whole app down

A schema change can lock the table. Most people know that. What they usually do not know is which lock, and what it conflicts with.

From the PostgreSQL documentation on ALTER TABLE, the sentence that matters:

Note that the lock level required may differ for each subform. An ACCESS EXCLUSIVE lock is acquired unless explicitly noted.

· PostgreSQL documentation, ALTER TABLE

And ACCESS EXCLUSIVE conflicts with everything, including plain reads. A SELECT takes an ACCESS SHARE lock, and the only thing ACCESS SHARE conflicts with is ACCESS EXCLUSIVE. So a routine ALTER TABLE is not a write freeze. It is a total blackout on that table.

Two more pieces of mechanism. Locks are held until the end of the transaction, not until the statement finishes, so several ALTER TABLEs in one migration file hold every lock until the last one commits. And a transaction waiting for a lock waits indefinitely by default.

Put those together and you get the failure mode that catches people out: a slow migration does not merely block, it forms a queue. The migration waits behind whatever long query is already running, and every ordinary read that arrives afterwards queues behind the migration. Your app goes down while the migration has not even started.

Sourcing caveat worth stating plainly. The individual mechanics above are all in the official PostgreSQL documentation. The specific claim that a queued, not yet granted lock blocks the readers behind it is not, and I could only find it stated in vendor engineering writing, most clearly by Marco Slot at Citus Data and in GitLab's migration style guide. Both include reproducible demonstrations. Treat it as well attested rather than officially documented.

The mitigation is lock_timeout, which aborts a statement that waits too long for a lock without affecting statements that are actually running. Set it low enough that a stuck migration fails fast instead of parking at the head of the queue.

A conflict in the advice worth knowing about

Supabase's migrations guide suggests that if you hit a lock timeout error, you should consider increasing your lock_timeout setting.

That is the opposite of the consensus among people running Postgres at scale. GitLab's handbook and the strong_migrations project both argue for a short lock timeout, precisely so a migration that cannot get its lock quickly gives up rather than blocking everything behind it.

Both positions are defensible, because they optimise for different things. Supabase is optimising for your migration completing. GitLab is optimising for the application staying up. But they point in opposite directions, and a solo developer following only the Supabase note will take the riskier of the two paths without realising a choice was made.

My view: lower it. A failed migration is an inconvenience you retry in a quieter minute. A locked table is an outage.

Building an index without the outage

The specific case you will hit first, because the fix for a slow query is usually an index. A plain CREATE INDEX locks the table against writes for the whole build:

Normally PostgreSQL locks the table to be indexed against writes and performs the entire index build with a single scan of the table. This could have a severe effect if the system is a live production database.

· PostgreSQL documentation, CREATE INDEX

CREATE INDEX CONCURRENTLY avoids that, at the cost of two table scans and more total time. Two things to know before you use it. It cannot run inside a transaction block. And if it fails partway it leaves behind an invalid index that is ignored for queries but still costs you on every write, which you fix by dropping it and trying again.

On Supabase specifically, the answer to “can I put CONCURRENTLYin a migration file” is annoyingly conditional. Under db push it works, because the CLI detects statements that cannot be pipelined and runs them standalone. Under Supabase Branching it fails, and that one is documented explicitly: branching runs each migration file inside a single transaction, so a migration using create index concurrently applies with db push but fails when branching deploys it. Any confident yes or no answer you read on this is wrong.

The honest answer on zero downtime migrations

There is a real technique here, the expand and contract pattern: add the new column, write to both, backfill, switch reads, drop the old one. Several deploys, no single breaking moment. It works and it is what large teams do.

It is also usually the wrong trade for a small app. Web Dev Cody puts the alternative plainly:

I would say though if you have the flexibility to just turn off your system for like 30 minutes, run the migration and turn it back on, it'll be a lot easier than having to orchestrate this multi-step deployment.

· Web Dev Cody, How do software projects achieve zero downtime database migrations?

A maintenance page at 3am on a Tuesday costs you almost nothing and removes an entire category of risk. The multi-step dance costs you several deploys and a window in which your code must handle both schemas correctly. Pick the cheap one until you have users who would notice.

One widely repeated warning you can stop worrying about. “Adding a column with a default rewrites the whole table” has been false since PostgreSQL 11 for constant defaults, which is what you almost always have. The release notes are explicit that no rewrite is required. It is still true for volatile defaults like gen_random_uuid(). Supabase runs Postgres 15 and 17, so the optimisation always applies there.

Canary releases do not work at your traffic

Blue-green deployment and canary releases are real techniques with precise definitions. A canary sends the new version to a small subset of users first, watches, then widens.

The problem at small scale is statistical, and Vercel says so in its own documentation for the feature: randomised assignment based on hashing may not achieve the desired rate, especially when the number of sessions is small, and a single high traffic user landing in one bucket can skew the split.

A canary at fifty daily users is not an experiment, it is a coin flip. It is also a paid feature that Vercel recommends pairing with another paid feature. The free version of the same risk reduction is the one you already have: deploy, watch, roll back instantly if it is wrong.

Feature flags, for the right reason

Flags are worth it for one person, but not for the reason they are usually sold. You are not doing gradual rollouts. You want a kill switch that does not require a build.

The difference matters when something is actively going wrong. Changing code means editing, pushing, waiting for a build. A flag is a toggle. For anything that touches money, sends messages to real people, or calls a paid API, that gap is the reason to bother.

The cost is real too, and the best statement of it is Pete Hodgson's:

Savvy teams view their Feature Toggles as inventory which comes with a carrying cost, and work to keep that inventory as low as possible.

· Pete Hodgson, Feature Toggles, martinfowler.com

Which gives you the discipline: a short-lived flag can be a plain if statement, and Hodgson says so explicitly. Delete it when the feature is settled. Keep the long-lived ones only where you genuinely want an off switch.

The one person postmortem

Blameless postmortems solve a problem you do not have, which is people hiding information to avoid being punished. Alone, there is nobody to blame.

But the underlying bias survives perfectly well, and John Allspaw's framing of it is the best thing I have read on the subject:

What you look for is what you find. What you call root cause is simply the place where you stop looking. There are contributors, not causes, because there is no root single cause.

· John Allspaw, Outages, Post Mortems, and Human Error 101, Etsy, 2014

And on where an investigation should begin rather than end:

Human error is not the place where you stop. Human error is the place where you start, and that's where you start asking questions.

· John Allspaw, Outages, Post Mortems, and Human Error 101, Etsy, 2014

“I should have known better” is the solo developer's version of blame. It feels like accountability and produces nothing, because it names no change. Allspaw's replacement question is the entire one person practice: why did it make sense at the time? Answer that honestly and the fix is usually obvious, and it is usually a system change rather than a resolution to be more careful.

Five lines in a file in the repo is enough:

  • What users actually experienced, and for how long.
  • What happened, in order.
  • Why it made sense at the time.
  • What would have told me sooner.
  • One change, with a date.

The last one carries the weight. From the SRE Workbook: “To our users, a postmortem without subsequent action is indistinguishable from no postmortem.”

What this adds up to

  • Deploy freely. Rollback is instant and free. Know that it does not revert env vars, cron state or your database, and that it switches off auto-assignment of your production domain.
  • Never touch the production database by hand. It breaks your next deploy, not this one.
  • Write the undo migration before you push the risky one. There is no other rollback.
  • Set a short lock timeout so a stuck migration fails instead of queueing your app behind it.
  • Use CONCURRENTLY for indexes on live tables, and know it breaks under branching.
  • Take the maintenance window. Thirty minutes of downtime beats a four-deploy dance you have never rehearsed.
  • Skip canary releases until the split would mean something.
  • Flag anything that spends money, and delete the flag afterwards.

Find out which of those apply to you

Fourteen questions, about three minutes, runs entirely in your browser. You get a ranked list of what's actually open, with the fix for each.

Run the free check

Sources

Quotations from the two interviews are transcribed from the published videos and lightly condensed for readability.