More in Migrations & upgrades.
Migrate a 180M-row Postgres table to bigint with Claude Code
Claude Code wrote most of a nine-day bigint migration with a 1.4-second lock, but twice suggested steps that would have failed.
Result: WorkedTool: Claude CodeLevel: AdvancedEvidence: Shown
Shown: The post shows the database alert and the migration code written with Claude Code. Rated , after reopening the source. Rates the evidence, not the result. Failed and partial cases are rated the same way. How we rate evidence
Outcome
The busiest table in yureki_lab's app, events, was about 41 days from running out of int4 primary-key values. It had 180 million rows (about 210 GB with indexes), took around 1,400 inserts a second at peak and was referenced by three other tables. A one-line ALTER TABLE had locked it for 3 hours and 12 minutes in a staging rehearsal. Working in Claude Code with read access to the schema and a staging database, the developer first had it map every foreign key, index, view, trigger and application query that depended on the id without proposing a fix. That turned up 3 foreign-key columns, 4 indexes, a materialized view and 11 ORM queries, including two casts the developer didn't know about. Claude Code then helped write an expand-and-contract migration: a new bigint column kept in sync by a trigger, a throttled, resumable backfill that ran about 5.5 days with replica lag peaking at 4.1 seconds, a concurrent index build that took 47 minutes, and a swap rehearsed six times on staging that held its lock for 1.4 seconds in production. The whole migration took nine days with no locked writes. Claude Code was confidently wrong twice: it put a concurrent index build inside a transaction, which Postgres rejects, and its "simplified" swap would have held an exclusive lock for 4 minutes and 38 seconds, as staging showed. The developer says Claude Code wrote about 90% of the scripts and SQL, while the developer owned the order of operations and the rollback plan.
WorkedPosted Last checked
- Source checked
- Results shared. The poster described their results. This doesn't mean proof is attached.
Level: Advanced. You need: A tool that takes actions for you or writes code, connected accounts, or some setup on your computer.
How to use this
- Tap Copy prompt.
- Open the tool the case used (or a similar one) and paste the prompt; results may differ from the original.
- Paste it into the message box.
- Replace anything in [CAPITAL LETTERS IN BRACKETS] with your own details.
- Send it, then read the answer before acting on it.
New to this? What's a prompt?
A prompt is the message you send to the AI tool. Copy the one on this page, put your own details where it asks, and read the answer before you act on it.
Prompt
Recreated prompt
The source didn't share its exact prompt, so we wrote one from what it describes. The result shown is the source's, not ours.
The person didn't share their exact words, so we wrote this from what they described. We haven't tested it, and they didn't use this exact version.
Our [TABLE] table's int4 primary key is about to run out. Find every foreign key, index, view, trigger and application query that depends on [TABLE].id and output a table. Do not propose a fix yet. Then plan an expand-and-contract migration to bigint in which no statement holds a heavy lock for more than 2 seconds, and say which lock each statement takes.
Try this in:
This prompt has blanks to fill in, like [TABLE]. We'll copy it instead of filling it in, so you can edit it before you send.
The source used Claude Code, which can take actions on your computer or in a browser. These are general chat tools, so results may differ, and a normal chat may only give you a plan.
Opens in a new tab. We don't see what you send.
These links are only a shortcut. We're not affiliated with OpenAI, Google, Anthropic or xAI, and your results may not match the source.
Optional stronger version
Our rewrite with extra checks. The poster didn't test it.
Before you start, ask me 1–3 short questions about the details below and wait for my answers. Once I've answered, confirm the plan in one line and run the whole task start to finish. Goal: Migrate a large, busy table's primary key from int4 to bigint without downtime. Questions to ask me first: - How many rows, how many writes a second at peak, and how long until the sequence runs out? - Which tables, views and application queries reference the id? - What lock time and replica lag can production tolerate? Inputs (fill in or confirm): - Table and Postgres version: [TABLE, VERSION] - Limits: [MAX LOCK SECONDS, MAX REPLICA LAG] - Staging database for rehearsals: [STAGING] Rules: - Inventory every dependency first; don't propose a fix until I've seen the list. - Set lock_timeout on every DDL statement and state which lock each statement takes. - Backfill in resumable primary-key ranges with a replica-lag check. - Never "simplify" a lock-sensitive step without a staging rehearsal. Checkpoint: Show me the dependency table and the step-by-step plan before writing any migration. If you get stuck: If a step needs a long exclusive lock, stop and propose an alternative. Verify before you finish: Rehearse the swap on staging and report how long each lock was held. Output: The migration files, the backfill script and a rollback plan for every step. Done when: The id column is bigint in production, writes never stopped, and the old column can be dropped.
AI tool
Source
- Posted
- by yureki_lab (DEV Community)
- Last checked
- Method:
- How we verify
Context: Firsthand DEV Community post dated October 10, 2026, by a pseudonymous developer. All figures are the author's own. The inventory request in the prompt is quoted from the post; the rest of the prompt is recreated. The author says Claude Code was useful for the scripts and wrong about locking, so rehearse every step on staging.
Tell us how it went A reader message. It is not published on this page, and it is not a test of the prompt.
More in Migrations & upgrades
Migrate two websites from WordPress to Wagtail with Claude Code
Over a weekend Claude Code moved two sites from WordPress to Wagtail, including server setup and testing; the poster says nothing broke.
WorkedClaude CodeEvidence: Described by posterAdvancedView CasePort a backend to Convex in four hours with Factory's Droid
The poster reports Factory Droid ported a tRPC/Drizzle backend to Convex in about 4 hours, with some bugs left to fix.
WorkedFactory DroidEvidence: Described by posterAdvancedView CaseMigrate a 50-screen app from Firebase to Supabase with Claude Code
Going feature by feature with Claude Code, the poster moved about 85% of a 50-screen app from Firebase to Supabase in 10–20 days.
WorkedClaude CodeEvidence: Described by posterAdvancedPoster says: ~85% migrated in 10–20 days
View CaseMigrate 180 microservices to a new framework version with Cursor agents
Brex reports its self-hosted Cursor agents let one engineer migrate 180 microservices from Micronaut 3 to 4 in a month.
WorkedCursor (self-hosted agents)Evidence: Company case studyAdvancedAccording to Brex: 180 microservices migrated in one month
View CasePort an HTML5 parser from Python to JavaScript with Codex CLI
Codex CLI ran largely unattended for about 4.5 hours and produced 9,000 lines of JavaScript passing 9,200 html5lib tests.
WorkedOpenAI Codex CLIEvidence: Screenshots or logsAdvancedPoster says: Passes 9,200 html5lib tests
View CaseUpgrade a plugin to a new framework alpha with Codex CLI
A one-line Codex CLI loop read the Datasette 1.0a20 upgrade docs, fixed the failing tests and got a plugin passing again.
WorkedOpenAI Codex CLIEvidence: Screenshots or logsAdvancedView Case

