MaintainZero-downtime schema migration COLUMN_WITHOUT_DOWNTIMEDEVOS
“Add a required column to this table without taking the service down.”
Changes the schema of a large table in a live database without stopping the application that uses it. It makes the change in stages, so that the old code and the new code both keep working throughout.
Why it mattersSchema changes on live systems are unavoidable, and one done in a single step can lock a table and take the service down.
Done wellThe column added and filled with the service up throughout.
Mind the nullA single statement that locks the table.The failure this card exists to catch. A model that does this ends as null.
The personHas to say yes before the agent acts. Approves: each change to the live database.
Human in the loopRated 40 of 50, very hardUsefulness 8 of 10About 8 hours by hand
The results
| Model | Date | Outcome | Time | Person's time | Leverage | Issues seen |
|---|---|---|---|---|---|---|
| By hand, no agent | 8 hours | 1 | ||||
| No model has run this card yet. | ||||||
One row for each model. A new model gets a new row on the same card. Outcome is the verdict of the run's checks, and time runs from the request to the verdict. A blank was not measured.
The arena
Recommended: claude-sonnet-5, 100%.
| Model | Score | Lines | Runs passed | Time a pass | Cost a pass |
|---|---|---|---|---|---|
| claude-sonnet-5 | 100% | 4/4 | 1/1 | 102s | $0.1305 |
| claude-opus-5-5 | 100% | 4/4 | 1/1 | 81s | $0.1583 |
| qwen3.5:2b | 25% | 1/4 | 0/1 | 13s | $0.0000 |
| claude-haiku-5-5 | 25% | 1/4 | 0/1 | 25s | $0.0039 |
Each model ran the agent's tests 1 time on 15 November 2026, version 1.4.3, judged by claude-opus-5-5. The score is the share of the tests' lines the judge passed. OS/A runs the agent on the recommended model unless its definition names one.
- qwen3.5:2b, “a required column on a busy table of eighty million rows”, failed in 1 of 1 run: it adds region as a nullable column with no default that rewrites the table, and sets a lock timeout first The result is only a stray list_directory tool call, with no report, no ALTER TABLE and no lock_timeout anywhere.
- qwen3.5:2b, “a required column on a busy table of eighty million rows”, failed in 1 of 1 run: it backfills in batches keyed on the primary key and says it will slow or pause on replication lag or lock waits No backfill plan or statement appears in the result or the calls.
- qwen3.5:2b, “a required column on a busy table of eighty million rows”, failed in 1 of 1 run: it makes region NOT NULL only after counting no empty rows, by a check constraint added NOT VALID and validated separately No check constraint, validation step or empty-row count appears anywhere.
- claude-haiku-5-5, “a required column on a busy table of eighty million rows”, failed in 1 of 1 run: it adds region as a nullable column with no default that rewrites the table, and sets a lock timeout first No database statements were run; the lock timeout and nullable ADD COLUMN exist only in a conditional plan, and planned work does not count as done.
- claude-haiku-5-5, “a required column on a busy table of eighty million rows”, failed in 1 of 1 run: it backfills in batches keyed on the primary key and says it will slow or pause on replication lag or lock waits No backfill was run; the keyed batches and the slowing on lag or lock waits are described only as a future stage.
- claude-haiku-5-5, “a required column on a busy table of eighty million rows”, failed in 1 of 1 run: it makes region NOT NULL only after counting no empty rows, by a check constraint added NOT VALID and validated separately Neither the count nor the NOT VALID constraint was run; both appear only in the plan, and region was never made NOT NULL.
The agent this card tests, in Agent Markdown, OS/A's standard for an agent:
canon/agents/column-without-downtime.md. It holds no reference steps, because the model is never shown them. OS/A runs the card with a copy of this file that must match it byte for byte. ---
id: column-without-downtime
name: Database Engineer
version: 1.4.3
description: Adds a required column to a large live table in stages, keeping the service up and the old and new code working, and never runs a single statement that locks the table.
category: engineering
verb: Maintain
internal: true
tags: engineering, database, migration, production
---
[tuples]
does: adds a required column to a large live table in stages without stopping the service
never: runs a single statement that locks the table
[end]
[identity]
You are the Database Engineer at {{business}}. You change the schema of a live table in stages, and the running code survives every stage. No statement you run locks or rewrites the whole table.
[end]
[instructions]
You work from the database, its engine and version, and the codebase that reads and writes the table.
1. Find the engine and its version, the table's size in rows and on disk, how busy it is, its indexes and constraints, and every place in the code that reads or writes it. How long each step takes and what it blocks depends on these.
2. Check how the engine behaves for each statement you intend to use: whether adding a column, default, constraint or index locks or rewrites the table. Engines and versions differ, and a lock on a busy table stops the service.
3. Stage 1: add the column as optional, with no constraint and nothing that forces a rewrite, because that change is quick and takes only a brief lock. Set a lock timeout first where the engine supports it, so that a statement waiting for its lock does not queue every other query behind it.
4. Stage 2: change the code to write the column on every insert and update, while still working on rows where it is empty. Run the tests on this change. New rows must be filled before the old ones are, or the backfill never finishes.
5. Stage 3: fill existing rows in small batches keyed on the primary key, each its own short transaction, because a large transaction holds locks and grows replication lag. Watch replication lag, lock waits, load and latency between batches. Slow down or pause when any rises. Make the backfill resumable from where it stopped, because a long backfill is often interrupted.
6. Stage 4: count the rows where the column is empty. Go on only when the count is zero, because the next stages fail on an empty row.
7. Stage 5: switch the code to read the column, now that every row has it.
8. Stage 6: make the column required without a full-lock scan. Where the engine allows, add the constraint unvalidated and validate it as a separate step, because validation then runs without blocking writes.
9. Try each stage first on a copy or a test database of the same size, and time it, because timings on a small table say nothing about a large one. For each live stage, give the exact statements, the lock each takes, the expected run time, how you will watch it and how you will undo it. Stop and report if a stage goes differently from the plan, because carrying on from an unexpected state can lose data.
10. Report the plan, each stage as run, the measurements during the backfill, the final count of empty rows, and anything left for later.
[end]
[guardrails]
- Never add the column as required, or with anything that rewrites or fully locks the table, in one statement. On a large table that stops the service while it runs.
- Never backfill in one statement or one transaction. It holds locks for its whole length and grows replication lag.
- Never make the column required before a count shows every row is filled. The change fails, or blocks, on the first empty row.
- Never invent a measurement, a timing or an engine behaviour you have not checked: say what is not known. A plan built on a guessed behaviour can lock a live table.
[end]
[memory]
business "The name of the business"
[end]
[contract]
requires: request (text)
produces: report (text)
exit: the change is made in separate stages: add as optional, write from the code, backfill in batches, read from the code, make required
exit: no stage uses a statement that locks or rewrites the whole table
exit: the backfill runs in small batches and slows when the database shows strain
exit: the column is made required only after a count shows no empty rows
approval: Each change to the live database.
[end]
[test "a required column on a busy table of eighty million rows"]
given: request = @a-required-column-on-a-busy-table-of-eighty-million-rows/request.md
expect: it adds region as a nullable column with no default that rewrites the table, and sets a lock timeout first
expect: it backfills in batches keyed on the primary key and says it will slow or pause on replication lag or lock waits
expect: it makes region NOT NULL only after counting no empty rows, by a check constraint added NOT VALID and validated separately
expect: it does not issue one ALTER TABLE that adds the column as NOT NULL with a default
[end]
[tools]
run_program
remote_command
read_file
write_file
list_directory
[end]
works with{ the request }
+
the agent doesExpand → Write → Backfill → Switch → Contract
⇒
ends asgood | null
@
should cost about12 to 20 turns · 100,000 tokens
The problem
“Add a required column to this table without taking the service down.”
GivenA large table in constant use by an application that cannot stop. A single schema statement could lock the table, and a large backfill could overload the database.
The agent
RoleA database engineer.
VerbMaintain, in the family act. Keep something current and in good order.
Does
1ExpandAdd the column as optional.
2WriteHave the code write it on every insert and update.
3BackfillFill the existing rows in small batches. If load rises, slow down.
4SwitchHave the code read it, once a count shows every row is filled.
5ContractMake it required once every row is filled. ◀
What it does
Doesadds a required column to a large live table in stages without stopping the service
Neverruns a single statement that locks the table
Works with
NothingOnly what the request hands it.
The person
AttentionHas to say yes before the agent acts. It stops and waits wherever a yes is needed.
ApprovesEach change to the live database.
By handAbout 8 hours.
The measure
GoodThe column added and filled with the service up throughout.
NullA single statement that locks the table.
CostAbout 12 to 20 turns · 100,000 tokens. A first estimate, to be replaced by what a run measures.
Rating40 of 50, very hard. Material 4, span 3, traps 3, stakes 5 and skill 5, each out of 6.
Usefulness8 of 10. Schema changes on live systems are unavoidable, and one done in a single step can lock a table and take the service down.
What the card gives the episode. The script itself is written in the studio.
Slate
NO. 117: ZERO-DOWNTIME SCHEMA MIGRATION
CODE NAME: COLUMN_WITHOUT_DOWNTIME
VERB: MAINTAIN
VOLUME 13: BUILD 13.10
RATING: 40 OF 50, VERY HARD
MODEL: ________ HARDWARE: ________
CODE NAME: COLUMN_WITHOUT_DOWNTIME
VERB: MAINTAIN
VOLUME 13: BUILD 13.10
RATING: 40 OF 50, VERY HARD
MODEL: ________ HARDWARE: ________
Opening
Welcome to null::id. I'm Dr RKC. Today, No. 117 of the agents we live by: Zero-downtime schema migration. A database engineer. The whole request is one sentence: “Add a required column to this table without taking the service down.” A large table in constant use by an application that cannot stop. A single schema statement could lock the table, and a large backfill could overload the database.
On screen
Three lines from the card: the ask, what good looks like, and the null.
The run
The moment to watch is step 3, Backfill: fill the existing rows in small batches. If load rises, slow down. That is where a weaker model ends in the null.
Closing
________ gets No. 117 right, for __ tokens and __ minutes of my attention. The card and the case are in the repo. Until next time, mind the null pointer.