Practise this: Change a live column in four steps
Clone the starter: https://github.com/codeprepdev/agentic-engineering-lab-6-change-a-live-column-in-four-steps. It is the appointment book for four vet clinics, in Python with the standard library only, on SQLite. The front desk books from a web screen and the vets read their day from tablets. A deploy replaces one server at a time, so for a few minutes the previous release and the new one run against the same database. Run python3 -m unittest discover, then read the README and AGENTS.md.
The ticket:
Ama (practice manager): The new online booking page has to find free slots, and it can't do sums with "1h 15m". Store each appointment's length as a number of minutes.
Today the length is appointments.duration, the text the front desk typed. It moves to a new column, duration_minutes, a whole number. That is a change to a column that live code reads, so it goes out in four steps, each its own pull request: add, fill, switch, remove. Which step is running will be two settings you add to clinic/settings.py (the starter has neither yet), which book, change_length and day_list read at the moment they run:
DURATION_WRITES, where a length is saved:("text",)for what the code does today,("text", "minutes")from the add step,("minutes",)at the end;DURATION_READS, whereday_listreads it:"text"until the switch, then"minutes".
0. See the agent's default. Give an agent the ticket as Ama wrote it and ask for a plan, without naming the steps. Note what it proposes; do not build it. Then brief it one step at a time, naming which step this is and what it must not touch.
1. Add. A new migration adds duration_minutes, allowed to be empty, with no default and no copying. Set DURATION_WRITES = ("text", "minutes"), leave DURATION_READS = "text", and make booking and changing a length write both.
2. Fill. Write clinic/backfills/duration_minutes.py with run(conn, batch_size=200), which copies each length into minutes in batches, commits each batch, and resumes where a stopped run left off. It returns {"filled": rows it changed, "unparsed": [ids]}. Add mismatches(conn), which counts rows still to fix: minutes empty, or minutes that disagree with the text. Tell the agent to stop and report any length it cannot read rather than guess. When it does, the answer from Ama is: "Book those as 30 minutes, the standard consult, and list them in the pull request." Run it on the sample database (python3 -m clinic.seed clinic.db, then python3 -m clinic.migrate clinic.db) and expect 0 mismatches.
3. Switch. Set DURATION_READS = "minutes", still writing both. Then, as its own change, DURATION_WRITES = ("minutes",). That release still runs against a database where duration exists.
4. Remove. Run the restore drill first, python3 scripts/restore_drill.py clinic.db, on the filled sample database. Then a separate, later migration drops duration, and nothing in the code reads it. The starter's tests all stay, by name; one of them writes the old column, so it changes with the column.
Write STEPS.md with a heading for each step, Add, Fill, Switch and Remove. Under each, put what you briefed the agent and what a rollback straight after that step would leave. Under Remove, paste the restore drill's output line as printed. Leave clinic/settings.py on the final release.
Get python3 -m unittest discover passing, and read the output yourself, then upload the repository folder. The upload leaves out the .git folder, so the hidden tests see your files and no commit history. On fresh databases built from your migrations they run each step: rows booked before the add migration, the release before still booking beside the new column, the add release writing both and reading the text, the fill (every length, the unreadable ones, a server that stops it partway, a second run), the mismatch count, the switch, writing minutes only before the drop, and booking after it. They also check the two migrations, the settings you leave in place, the starter's tests (all there, none skipped) and STEPS.md.
Open the lab · needs a free Tarmac account to have your work marked