How many tokens does a data migration take with AI?
A data / schema migration typically takes about 550,000 tokens to build with an AI coding agent (roughly 212,000–1,268,000 depending on complexity), about $1.60 at today's GPT-4o prices ($0.6200–$3.68). This is the build-time (developer) cost, not the cost of running the finished feature.
A data migration is risky because it ripples: the schema change is small, but the agent has to find and update every reader and writer. Cost is driven by that dependency mapping, not the migration script itself.
Token & cost ranges
Cost uses GPT-4o at current prices. Verified 29 July 2026.
| Scenario | Input tokens | Output tokens | Total tokens | Est. cost |
|---|---|---|---|---|
| Low (simple) | 200,000 | 12,000 | 212,000 | $0.6200 |
| Typical | 520,000 | 30,000 | 550,000 | $1.60 |
| High (complex) | 1,200,000 | 68,000 | 1,268,000 | $3.68 |
Typical cost by model
The same typical token estimate priced across a few common coding models.
| Model | Typical cost | Range (low–high) |
|---|---|---|
| GPT-4o | $1.60 | $0.6200 – $3.68 |
| GPT-4o mini | $0.0960 | $0.0372 – $0.2208 |
| Claude Sonnet 4.6 | $2.01 | $0.7800 – $4.62 |
| Gemini 2.0 Flash | $0.0640 | $0.0248 – $0.1472 |
How we estimate this
A migration touches the schema plus every place that reads/writes it — the agent maps dependencies, writes the migration, and updates callers. Input tokens dominate because an agent re-sends file context on every turn; output is the generated code, diffs and tests. Treat these as planning ranges, not a quote — your real usage depends on codebase size, model, prompt caching and how many iterations it takes.
Examples of this size
- Renaming a column and updating queries
- Adding a table and backfilling data
- Splitting a field across two tables
Estimate it with your own model
Plug in your model, complexity and prompt-caching to get a tailored range.
Frequently asked questions
How many tokens does a data / schema migration take to build with AI?+
A data / schema migration typically takes about 550,000 tokens to build with an AI coding agent (roughly 212,000–1,268,000 depending on complexity), about $1.60 at today's GPT-4o prices ($0.6200–$3.68). This is the build-time (developer) cost, not the cost of running the finished feature.
Is this the cost to build it or to run it?+
This is the build-time (developer) cost — the tokens an AI coding agent burns while implementing the work. Running the finished feature is a separate, usually much smaller per-request cost.
Why is the range so wide?+
A migration touches the schema plus every place that reads/writes it — the agent maps dependencies, writes the migration, and updates callers. Input tokens dominate because an agent re-sends file context on every turn; output is the generated code, diffs and tests. Treat these as planning ranges, not a quote — your real usage depends on codebase size, model, prompt caching and how many iterations it takes.
How can I lower the cost?+
Split large work into smaller pieces, enable prompt caching so re-sent context is billed at the cheaper cache-read rate, and use a cheaper model for routine steps. Try your own model in the Cost to build X estimator.