EasyEnv

Zero Downtime Database Migration Interview: Testing Backend Engineers on a Live Postgres

November 30, 2026·8 min read·By EasyEnv·
Zero Downtime Database Migration Interview: Testing Backend Engineers on a Live Postgres

The candidate types ALTER TABLE orders RENAME COLUMN customer_ref TO customer_id; and presses Enter. The statement finishes instantly. Two seconds later the error-rate panel on the right side of the screen goes from a flat green line to a wall of red, because every running copy of the app is still selecting customer_ref, and that column no longer exists.

Nothing about that command is wrong as SQL. It is wrong as a change to a system people are using. That gap is what this interview measures, and almost no other format can see it.

This post is for backend hiring managers: the task, a box where a mistake shows up the second it happens, what strong candidates do, a rubric and a 60-minute plan.

What this interview tests, and what it does not

The database performance interview is about finding the missing index; the backup interview is about getting lost data back. This one is neither. The data is fine and the queries are fast. The candidate has to change the shape of a table while the application keeps working.

A local database with ten rows and no traffic accepts every migration. A production table with live writers punishes the wrong order, the wrong lock and the missing rollback.

The task

Give the candidate a short brief, written like a ticket:

The orders.customer_ref column holds customer ids as text. Rename it to customer_id and make it a bigint. The app is serving traffic and must keep serving it. The error rate must stay at zero for the whole change. You have 45 minutes. Leave the old column in place if you run out of time, and write down what is left.

A rename plus a type change is a good size. A pure rename can be faked with a view, and a type change alone invites a single ALTER COLUMN ... TYPE, which rewrites the table under an exclusive lock. Together they force the pattern the job needs.

The pattern a strong candidate reaches for: expand and contract

Expand and contract, also called parallel change, splits a breaking change into steps that are each safe on their own, with the app in either its old or new version. In this task:

  1. Expand. Add customer_id bigint as a nullable column with no default. No rewrite, short lock.
  2. Dual write. Change the app so every insert and update writes both columns. Deploy that. Some candidates use a trigger instead, which is a reasonable choice if they can say why.
  3. Backfill in batches. Copy old rows across in chunks of a few thousand, by primary key range, committing each batch. Not one UPDATE orders SET customer_id = customer_ref::bigint, which holds row locks on every row and bloats the table in one long transaction.
  4. Verify. Count rows where the new column is null or disagrees with the old one. It should reach zero and stay there.
  5. Switch reads. Deploy the app reading customer_id.
  6. Contract. Stop writing the old column, then drop it, in a later deploy.

The order matters more than any single command. Switching reads before the backfill finishes returns nulls. Dropping the old column before the last old app instance is gone produces exactly the red wall from the opening.

Lock awareness: where good candidates separate from the rest

The PostgreSQL documentation on ALTER TABLE says an ACCESS EXCLUSIVE lock is taken unless a form is noted otherwise. That lock conflicts with everything, including plain SELECT, per the lock conflict table. Adding a nullable column holds it only for a moment. The danger is the wait: if a long transaction is open on the table, the ALTER queues behind it, and the queries that arrive after the ALTER queue behind the ALTER. A metadata change that would take milliseconds stalls the whole table.

Things to listen for:

  • lock_timeout. A careful candidate sets it before any DDL, for example SET lock_timeout = '2s';, so the statement gives up instead of stalling traffic, then retries. The setting is documented under client connection defaults.
  • CREATE INDEX CONCURRENTLY. The new column needs an index if queries filter on it. A normal CREATE INDEX blocks writes for the duration. The CREATE INDEX docs explain that the concurrent form avoids that, cannot run inside a transaction block, and can leave an invalid index behind if it fails. Strong candidates check for that invalid index rather than assuming success.
  • Not null without a long lock. If the candidate wants customer_id to be NOT NULL, the safe route is a CHECK (customer_id IS NOT NULL) NOT VALID constraint, then VALIDATE CONSTRAINT, which the ALTER TABLE page says takes only a SHARE UPDATE EXCLUSIVE lock, so reads and writes carry on while it scans. With that constraint validated, SET NOT NULL can skip its own table scan, as the same page describes.

A candidate does not need to quote any of this. What you want is the instinct to ask "what does this lock, and for how long" before pressing Enter.

The rollback plan

Ask for it before the first change, not after something breaks. A good answer names a rollback point for each step:

  • After expand: drop the new column. Nothing reads it.
  • After dual write: redeploy the previous app version. The old column is still complete.
  • After switching reads: switch back. Dual write means both columns are current.
  • After contract: there is no cheap rollback, which is exactly why the drop happens last, in its own deploy, after a waiting period.

The weak answer is "restore from backup", which loses every write since the backup was taken.

Building the box so mistakes are visible

The value of this interview depends on the candidate seeing consequences in real time. On EasyEnv we would set the box up with four parts:

  • Postgres with an orders table big enough that a careless UPDATE or blocking index build is noticeable, seeded by a script so every candidate gets the same data.
  • The app, a small HTTP service reading and writing orders, running as two instances with a deploy.sh that restarts one at a time, so the candidate has to think about a rolling deploy.
  • A load generator sending a steady, modest mix of reads and writes from the first minute. You want errors from locks and missing columns, not from CPU.
  • An error-rate and latency dashboard in a browser tab: requests per second, error count, p95 latency. One long-running transaction you start yourself, idle in a psql session, makes the lock queue scenario reproducible when you want to test it.

A Run tests button on the challenge checks the end state: the new column has the right type, no rows disagree, the app reads the new column and the load generator logged zero failures. That gives AI grading something concrete to score, and the session recording shows the order things happened in, which is most of the signal.

Let the candidate use the in-session AI panel. Asking an assistant whether ADD COLUMN locks the table is normal at work; the recording shows whether they checked the answer against the dashboard or pasted a migration and hoped. More in is using AI in technical interviews acceptable.

A 60-minute plan

Time What happens
0 to 5 min Interviewer shows the app, the dashboard and the brief. Candidate asks questions.
5 to 10 min Candidate writes the plan and the rollback plan in a notes file before touching anything.
10 to 40 min Expand, dual write, backfill, verify, switch reads. The interviewer stays quiet unless asked.
40 to 50 min Contract, or a written note of what is left and why it is safe to stop there.
50 to 60 min Debrief: "What would you do differently on a table a hundred times this size?" and "What breaks if the deploy stalls halfway?"

Running out of time before the drop is fine. Stopping with dual write in place and a clear note leaves the system safe; rushing the drop does not.

Rubric

Score each row 1 to 4. Have each interviewer score on their own before the debrief; on EasyEnv, interviewers do not see each other's votes until they have cast their own, which keeps the first opinion in the room from setting everyone's score. For writing rubric rows that hold up, see how to write a technical interview rubric.

Dimension 1 (weak) 4 (strong)
Sequencing Renames or alters type in place; errors appear Expand, dual write, backfill, switch, contract, in order, with app deploys between
Lock awareness Runs DDL with no thought for locks Sets lock_timeout, uses CONCURRENTLY, knows which statements wait on what
Backfill One giant UPDATE Batched by key range, committed per batch, watched on the dashboard
Verification Assumes it worked Queries for mismatches and nulls, checks for invalid indexes
Rollback "Restore from backup" A rollback point named for every step, before starting
Communication Silent until asked Narrates risk before each step, writes down what is left

Where this interview is not enough

It shows one kind of change on one database. It does not test schema design or query tuning. A candidate from a MySQL shop may know the pattern and stumble on Postgres lock names, so score the reasoning, not the vocabulary. And 45 minutes is a sample: pair it with a conversation about the worst migration they have shipped.

The short version

Give a backend candidate a live table, live traffic and a breaking change, and watch the error rate. The ones you want add before they remove, ask what each statement locks, backfill in small pieces and can undo every step. You learn that by watching, not by asking.

For hiring teams

Hire engineers with real-world interviews

Run live coding sessions and take-home challenges in real production environments. Watch sessions back, score consistently, and hire with confidence.

Continue reading

More posts you might like