# Expand-and-contract migrations (/docs/guides/database/data-migration) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Replace a column without downtime using the expand and contract pattern, with the data backfill inside a Prisma ORM migration. Location: Guides > Database > Expand-and-contract migrations ## Introduction [#introduction] When you change a production schema, you want the data to stay consistent and the app to keep running. The expand and contract pattern gets you there in two reviewable steps: first add the new column and copy the data across (expand), then remove the old column once nothing reads it (contract). In this guide you replace a `published` boolean on a `Post` model with a `status` enum. In Prisma ORM the data move is not a separate script. A migration is a TypeScript file, and the backfill is one more operation in it, a `dataTransform` that runs in the same transaction as the schema change. Every command and output below was run against a local PostgreSQL database. > [!NOTE] > Using Prisma ORM 7? > > Prisma ORM 8 is a [release candidate](https://www.prisma.io/docs/orm/release-status). Prisma ORM 7 remains fully supported; the Prisma ORM 7 version of this guide is at [/guides/v7/database/data-migration](https://www.prisma.io/docs/guides/v7/database/data-migration). ## Prerequisites [#prerequisites] - [Node.js](https://nodejs.org) 22.18 or newer on the 22 line, 24.11 or newer on the 24 line, or 26 or newer (24 recommended) - A PostgreSQL connection string for a development database, and one for the database you deploy to - Git, for the branch-per-migration workflow ## 1. Set up the project [#1-set-up-the-project] If you already have a Prisma ORM project whose contract is applied through migrations, skip to [step 2](#2-expand-the-contract). This step builds the starting point: a `Post` model with a `published` boolean, an `init` migration, and three rows of data. Create a project and add Prisma ORM to it: ```bash mkdir expand-contract && cd expand-contract ``` #### npm ```bash npm init npx prisma@latest orm init --yes --target postgres --authoring psl ``` #### pnpm ```bash pnpm init pnpm dlx prisma@latest orm init --yes --target postgres --authoring psl ``` #### yarn ```bash yarn init yarn dlx prisma@latest orm init --yes --target postgres --authoring psl ``` #### bun ```bash bun init bunx prisma@latest orm init --yes --target postgres --authoring psl ``` `orm init` writes `prisma.config.ts`, `src/prisma/contract.prisma`, `src/prisma/db.ts`, and `.env.example`, installs `@prisma/orm-postgres` and the `prisma` CLI, and emits the contract once. There is nothing to generate afterwards: the runtime reads the emitted `contract.json` directly, so there is no `prisma generate` step and no client package to install. `npm init -y` sets `"type": "commonjs"`, and `orm init` warns that the generated `db.ts` needs ES modules. Change it to `"type": "module"` in `package.json`. Put your development connection string in `.env`. Both `prisma.config.ts` and `db.ts` load it: ```bash title=".env" DATABASE_URL="postgres://user:password@localhost:5432/expand_contract" ``` Replace the generated contract with the starting model: ```prisma title="src/prisma/contract.prisma" // use prisma-8 model Post { id Int @id @default(autoincrement()) title String content String? published Boolean @default(false) } ``` Emit the contract, plan the first migration, and apply it. `db migrate` also records where your development database is, in the `db` ref, so the next `migration plan` knows what to diff against: #### npm ```bash npx prisma contract emit npx prisma migration plan --name init npx prisma db migrate ``` #### pnpm ```bash pnpm prisma contract emit pnpm prisma migration plan --name init pnpm prisma db migrate ``` #### yarn ```bash yarn prisma contract emit yarn prisma migration plan --name init yarn prisma db migrate ``` #### bun ```bash bunx prisma contract emit bunx prisma migration plan --name init bunx prisma db migrate ``` ```text no-copy ✔ Applied 1 migration(s) (2 operation(s)) across 1 contract space(s) App space ├─ Create schema "public" ├─ Create table "Post" └─ marker f7f98fd5c2b5983cfe78425d30f349fd8ffc1b6dd65427835f18b7a877f5cb5c ✔ Advanced ref "db" → f7f98fd5c2b5983cfe78425d30f349fd8ffc1b6dd65427835f18b7a877f5cb5c ``` Seed a few posts so the migration has data to move. Node.js runs TypeScript directly: ```typescript title="src/seed.ts" import { db } from "./prisma/db.ts"; await db.orm.public.Post.create({ title: "Hello World", content: "First post", published: true }); await db.orm.public.Post.create({ title: "Draft ideas", content: null, published: false }); await db.orm.public.Post.create({ title: "Release notes", content: "v1.0", published: true }); const posts = await db.orm.public.Post.select("id", "title", "published").all(); console.log(posts); await db.close(); ``` ```bash node src/seed.ts ``` ```text no-copy [ { id: 1, title: 'Hello World', published: true }, { id: 2, title: 'Draft ideas', published: false }, { id: 3, title: 'Release notes', published: true } ] ``` ## 2. Expand the contract [#2-expand-the-contract] Create a branch for the expand step: ```bash git checkout -b expand-post-status ``` Add the `Status` enum and a `status` field. Leave `published` in place; the app keeps working against it until the contract step. Prisma ORM stores an enum as `text` with a `CHECK` constraint, and the `@@type` line says so: ```prisma title="src/prisma/contract.prisma" // use prisma-8 model Post { id Int @id @default(autoincrement()) title String content String? published Boolean @default(false) status Status @default(Draft) // [!code ++] } enum Status { // [!code ++] @@type("pg/text@1") // [!code ++] Draft = "Draft" // [!code ++] InProgress = "InProgress" // [!code ++] InReview = "InReview" // [!code ++] Published = "Published" // [!code ++] } // [!code ++] ``` Emit the contract and plan the migration. Planning is offline; it diffs the emitted contract against the `db` ref and writes a migration directory: #### npm ```bash npx prisma contract emit npx prisma migration plan --name add_status ``` #### pnpm ```bash pnpm prisma contract emit pnpm prisma migration plan --name add_status ``` #### yarn ```bash yarn prisma contract emit yarn prisma migration plan --name add_status ``` #### bun ```bash bunx prisma contract emit bunx prisma migration plan --name add_status ``` ```text no-copy ✔ Planned 2 operation(s) migrations/app/20261120T1025_add_status ├─ Add column "status" to "Post" └─ Add check constraint "Post_status_check_eaa35e2a" on "Post" from: f7f98fd5c2b5983cfe78425d30f349fd8ffc1b6dd65427835f18b7a877f5cb5c to: 59c72dbbc671c87fa7d2e34e43928ed6fbcc0511c7dc19c3f028b5c4c5cbab9b app space: migrations/app/20261120T1025_add_status ℹ DDL preview ALTER TABLE "public"."Post" ADD COLUMN "status" text DEFAULT 'Draft' NOT NULL; ALTER TABLE "public"."Post" ADD CONSTRAINT "Post_status_check_eaa35e2a" CHECK ("status" IN ('Draft', 'InProgress', 'InReview', 'Published')); ``` Your directory name carries your own timestamp. The planner did not ask for a backfill because the column has a default, so every existing row would become `Draft`. That is wrong for posts that are already published. The next step fixes it. ## 3. Add the data migration [#3-add-the-data-migration] Open `migrations/app/_add_status/migration.ts`. It is the file the planner wrote, and you edit it like any other TypeScript. Add the imports and the line that build a typed SQL builder from this migration's own end contract, then append a `dataTransform` operation after the two schema operations: ```typescript title="migrations/app/20261120T1025_add_status/migration.ts" #!/usr/bin/env -S node import type { Contract as End } from '../../snapshots/59c72dbbc671c87fa7d2e34e43928ed6fbcc0511c7dc19c3f028b5c4c5cbab9b/contract'; import endContract from '../../snapshots/59c72dbbc671c87fa7d2e34e43928ed6fbcc0511c7dc19c3f028b5c4c5cbab9b/contract.json' with { type: 'json' }; import type { Contract as Start } from '../../snapshots/f7f98fd5c2b5983cfe78425d30f349fd8ffc1b6dd65427835f18b7a877f5cb5c/contract'; import startContract from '../../snapshots/f7f98fd5c2b5983cfe78425d30f349fd8ffc1b6dd65427835f18b7a877f5cb5c/contract.json' with { type: 'json' }; import { Migration, MigrationCLI, col, lit, sql } from '@prisma/orm-postgres/migration'; import postgres from '@prisma/orm-postgres/runtime'; // [!code ++] import { contractFromJson } from '@prisma/orm-postgres/static'; // [!code ++] const { sql: db, contract } = postgres({ contract: contractFromJson(endContract) }); // [!code ++] export default class M extends Migration { override readonly startContractJson = startContract; override readonly endContractJson = endContract; override get operations() { return [ this.addColumn({ schema: 'public', table: 'Post', column: col('status', 'text', { notNull: true, default: lit('Draft'), codecRef: { codecId: 'pg/text@1' }, }), }), this.addCheckConstraint({ schema: 'public', table: 'Post', constraint: 'Post_status_check_eaa35e2a', expression: sql`"status" IN ('Draft', 'InProgress', 'InReview', 'Published')`, }), this.dataTransform(contract, 'backfill-post-status', { // [!code ++] check: () => // [!code ++] db.public.Post // [!code ++] .select('id') // [!code ++] .where((f, fns) => fns.and(fns.eq(f.published, true), fns.ne(f.status, 'Published'))) // [!code ++] .limit(1), // [!code ++] run: () => // [!code ++] db.public.Post // [!code ++] .update({ status: 'Published' }) // [!code ++] .where((f, fns) => fns.and(fns.eq(f.published, true), fns.ne(f.status, 'Published'))), // [!code ++] }), // [!code ++] ]; } } MigrationCLI.run(import.meta.url, M); ``` The snapshot paths in your file carry your own contract hashes; keep the ones the planner wrote. `postgres(...)` is given the end snapshot's JSON and no connection string, so it builds the query builder and the contract object and never connects to a database. `sql: db` names the builder `db`, because the planned file already imports `sql` from `@prisma/orm-postgres/migration` for the check expression. Pass `contract`, not the JSON import `endContract`, to `dataTransform`. Three things to notice: - `check` is a query that returns a row while work remains. Prisma compiles it twice: as an `EXISTS` precheck that decides whether the step runs, and as a `NOT EXISTS` postcheck that proves the step finished. - `run` is the update. Both closures are typed against the migration's own contract snapshot, which is why `f.status` type-checks even though the column does not exist in the database yet. - There is no `published: false` branch. Those rows take the column default, `Draft`, when `ADD COLUMN` runs. Recompile the migration. Running the file regenerates `ops.json`, the file `db migrate` actually executes, and re-signs `migration.json`: ```bash node migrations/app/20261120T1025_add_status/migration.ts ``` ```text no-copy Wrote ops.json + migration.json to /Users/you/expand-contract/migrations/app/20261120T1025_add_status ``` Review what the backfill compiled to. `migration show` lists the operation: #### npm ```bash npx prisma migration show 20261120T1025_add_status ``` #### pnpm ```bash pnpm prisma migration show 20261120T1025_add_status ``` #### yarn ```bash yarn prisma migration show 20261120T1025_add_status ``` #### bun ```bash bunx prisma migration show 20261120T1025_add_status ``` ```text no-copy ✔ 20261120T1025_add_status from: f7f98fd5c2b5983cfe78425d30f349fd8ffc1b6dd65427835f18b7a877f5cb5c to: 59c72dbbc671c87fa7d2e34e43928ed6fbcc0511c7dc19c3f028b5c4c5cbab9b hash: 03c3f15c9f3aa9ea640be5f47b0d9df992fb28b518916e854cf955e73a7f7d7e created: 2026-11-20T10:25:35.909Z 3 operation(s) ├─ Add column "status" to "Post" ├─ Add check constraint "Post_status_check_eaa35e2a" on "Post" └─ Data transform: backfill-post-status ℹ DDL preview ALTER TABLE "public"."Post" ADD COLUMN "status" text DEFAULT 'Draft' NOT NULL; ALTER TABLE "public"."Post" ADD CONSTRAINT "Post_status_check_eaa35e2a" CHECK ("status" IN ('Draft', 'InProgress', 'InReview', 'Published')); ``` The DDL preview lists only the schema statements; the data transform's SQL is in `ops.json`: ```json title="migrations/app/20261120T1025_add_status/ops.json (the data operation)" no-copy { "id": "data_migration.backfill-post-status", "operationClass": "data", "precheck": [{ "sql": "SELECT EXISTS (SELECT \"id\" AS \"id\" FROM \"public\".\"Post\" WHERE (\"published\" = $1 AND \"status\" != $2) LIMIT 1) AS ok", "params": [true, "Published"] }], "execute": [{ "sql": "UPDATE \"public\".\"Post\" SET \"status\" = $1 WHERE (\"published\" = $2 AND \"status\" != $3)", "params": ["Published", true, "Published"] }], "postcheck": [{ "sql": "SELECT NOT EXISTS (SELECT \"id\" AS \"id\" FROM \"public\".\"Post\" WHERE (\"published\" = $1 AND \"status\" != $2) LIMIT 1) AS ok", "params": [true, "Published"] }] } ``` Commit `migration.ts`, `ops.json`, and `migration.json` together. Recompiling stores a hash of `ops.json` and `migration.json` inside `migration.json`. If either file changes after that, `db migrate` refuses to run the migration, and `npx prisma migration check` reports the same problem before you commit. ## 4. Apply the expand migration [#4-apply-the-expand-migration] Apply it to your development database. On PostgreSQL the whole run is one transaction, so the column, the constraint, and the backfill land together or not at all: #### npm ```bash npx prisma db migrate ``` #### pnpm ```bash pnpm prisma db migrate ``` #### yarn ```bash yarn prisma db migrate ``` #### bun ```bash bunx prisma db migrate ``` ```text no-copy ✔ Applied 1 migration(s) (3 operation(s)) across 1 contract space(s) App space ├─ Add column "status" to "Post" ├─ Add check constraint "Post_status_check_eaa35e2a" on "Post" ├─ Data transform: backfill-post-status └─ marker 59c72dbbc671c87fa7d2e34e43928ed6fbcc0511c7dc19c3f028b5c4c5cbab9b ✔ Advanced ref "db" → 59c72dbbc671c87fa7d2e34e43928ed6fbcc0511c7dc19c3f028b5c4c5cbab9b ``` Check the rows. The published posts moved to `Published`, and the draft kept the default: ```typescript title="src/posts.ts" import { db } from "./prisma/db.ts"; const posts = await db.orm.public.Post .select("id", "title", "published", "status") .orderBy((p) => p.id.asc()) .all(); console.log(posts); await db.close(); ``` ```bash node src/posts.ts ``` ```text no-copy [ { id: 1, title: 'Hello World', published: true, status: 'Published' }, { id: 2, title: 'Draft ideas', published: false, status: 'Draft' }, { id: 3, title: 'Release notes', published: true, status: 'Published' } ] ``` Both columns exist now, so this is the moment to move application code from `published` to `status`. The new field is typed as `'Draft' | 'InProgress' | 'InReview' | 'Published'` in the emitted contract: ```typescript const published = await db.orm.public.Post .select("id", "title", "status") .where((p) => p.status.eq("Published")) .orderBy((p) => p.id.asc()) .all(); ``` ```text no-copy [ { id: 1, title: 'Hello World', status: 'Published' }, { id: 3, title: 'Release notes', status: 'Published' } ] ``` Merge the branch and deploy it. Wait until nothing reads or writes `published` before you continue. ## 5. Contract the schema [#5-contract-the-schema] Create a branch for the cleanup: ```bash git checkout -b drop-published-column ``` Remove the old field: ```prisma title="src/prisma/contract.prisma" model Post { id Int @id @default(autoincrement()) title String content String? published Boolean @default(false) // [!code --] status Status @default(Draft) } ``` Emit and plan. Dropping the column loses its data, so `migration plan` asks before it writes anything; `--delete Post.published` answers in advance: #### npm ```bash npx prisma contract emit npx prisma migration plan --name drop_published --delete Post.published ``` #### pnpm ```bash pnpm prisma contract emit pnpm prisma migration plan --name drop_published --delete Post.published ``` #### yarn ```bash yarn prisma contract emit yarn prisma migration plan --name drop_published --delete Post.published ``` #### bun ```bash bunx prisma contract emit bunx prisma migration plan --name drop_published --delete Post.published ``` ```text no-copy ✔ Planned 1 operation(s) migrations/app/20261120T1026_drop_published └─ ⚠ Drop column "published" from "Post" ⚠ This migration contains destructive operations that may cause data loss. Statements applied └─ delete field "Post.published" (1 operation) from: 59c72dbbc671c87fa7d2e34e43928ed6fbcc0511c7dc19c3f028b5c4c5cbab9b to: 9ed66fdbf8c74bc42d6f006c71a05bfc7d7878ffcaaff4afe740753da669b0c6 app space: migrations/app/20261120T1026_drop_published ℹ DDL preview ALTER TABLE "public"."Post" DROP COLUMN "published"; ``` Nothing to edit this time. Apply it: #### npm ```bash npx prisma db migrate ``` #### pnpm ```bash pnpm prisma db migrate ``` #### yarn ```bash yarn prisma db migrate ``` #### bun ```bash bunx prisma db migrate ``` ```text no-copy ✔ Applied 1 migration(s) (1 operation(s)) across 1 contract space(s) App space ├─ ⚠ Drop column "published" from "Post" └─ marker 9ed66fdbf8c74bc42d6f006c71a05bfc7d7878ffcaaff4afe740753da669b0c6 ⚠ This migration contains destructive operations that may cause data loss. ✔ Advanced ref "db" → 9ed66fdbf8c74bc42d6f006c71a05bfc7d7878ffcaaff4afe740753da669b0c6 ``` The data survived the round trip. Drop `published` from the select in `src/posts.ts` and run it again: ```text no-copy [ { id: 1, title: 'Hello World', status: 'Published' }, { id: 2, title: 'Draft ideas', status: 'Draft' }, { id: 3, title: 'Release notes', status: 'Published' } ] ``` `migration log` reads the database's own ledger of what ran: #### npm ```bash npx prisma migration log ``` #### pnpm ```bash pnpm prisma migration log ``` #### yarn ```bash yarn prisma migration log ``` #### bun ```bash bunx prisma migration log ``` ```text no-copy Applied at Migration Change Ops 2026-11-20 21:25:27 +11:00 20261120T1025_init ∅ → f7f98fd 2 ops 2026-11-20 21:25:59 +11:00 20261120T1025_add_status f7f98fd → 59c72db 3 ops 2026-11-20 21:26:03 +11:00 20261120T1026_drop_published 59c72db → 9ed66fd 1 ops ``` ## 6. Deploy to production [#6-deploy-to-production] Production runs the same migrations from the same files; only the connection string changes. `db migrate` reads the database's marker, finds the path through the [migration graph](https://www.prisma.io/docs/orm/migrations/the-migration-graph), and applies whatever is pending, backfill included. Your deploy pipeline needs one command: #### npm ```bash npx prisma db migrate --db "$PRODUCTION_DATABASE_URL" ``` #### pnpm ```bash pnpm prisma db migrate --db "$PRODUCTION_DATABASE_URL" ``` #### yarn ```bash yarn prisma db migrate --db "$PRODUCTION_DATABASE_URL" ``` #### bun ```bash bunx prisma db migrate --db "$PRODUCTION_DATABASE_URL" ``` It refuses to run a migration whose `ops.json` or `migration.json` changed after it was compiled. If your pipeline deploys each environment to a ref, as [Applying a migration](https://www.prisma.io/docs/orm/migrations/applying-a-migration) shows, add `--to ` to that command. To see the route before it runs, add `--show`, which previews it without changing anything. Here is that preview against a production database that shipped the `init` migration and holds live rows, followed by the apply: ```text no-copy ℹ The following 2 migrations will run: 20261120T1025_add_status f7f98fd → 59c72db 20261120T1026_drop_published 59c72db → 9ed66fd ``` ```text no-copy ✔ Applied 2 migration(s) (4 operation(s)) across 1 contract space(s) App space ├─ Add column "status" to "Post" ├─ Add check constraint "Post_status_check_eaa35e2a" on "Post" ├─ Data transform: backfill-post-status ├─ ⚠ Drop column "published" from "Post" └─ marker 9ed66fdbf8c74bc42d6f006c71a05bfc7d7878ffcaaff4afe740753da669b0c6 ⚠ This migration contains destructive operations that may cause data loss. ``` In practice the two migrations reach production in separate deploys, and the app moves from `published` to `status` between them. If both migrations are on disk when you deploy, apply only the expand migration first with `--to _add_status`. Deploy the code that uses `status`, then run the command again without `--to` to drop `published`. Until the new code is live, the old code still writes `published` only, so a post it publishes after the backfill keeps the default `status` of `Draft`. So pause writes from the first command until the new code is live. Production never runs your TypeScript: the runner executes `ops.json`, which is plain data, so no application code runs with production credentials. ## Common gotchas [#common-gotchas] > [!WARNING] > Do not use `db update` for this change. It reconciles the database with the contract directly and does not carry data operations, so the backfill would not run. Use `migration plan` and `db migrate`, which is also what production needs: a reviewed, checked-in migration. > [!NOTE] > If `migration plan` stops with `MIGRATION.PLAN_ORIGIN_UNKNOWN`, the `db` ref is missing. That happens when you applied the migrations with `--db`, in CI, or with a release before `8.0.0-rc.25`. Point the ref at the last migration your database applied, with `npx prisma migration ref set db `, or pass `--from ` to the plan. > [!NOTE] > If `db migrate` reports `MIGRATION.CONTRACT_SPACE_VIOLATION`, or `migration check` reports `MIGRATION.CHECK_HASH_MISMATCH`, the migration's `ops.json` or `migration.json` changed after it was compiled, for example by a hand edit. Restore both files from Git, or move the edit into `migration.ts` and recompile with `node /migration.ts`, then apply again. Never edit `ops.json` by hand. > [!NOTE] > The `check` query must return rows, not a count. Prisma wraps it in `EXISTS` and `NOT EXISTS`; an aggregate always returns one row, so the step would never be skipped and the postcheck would always fail. ## Use with your agent [#use-with-your-agent] To delegate this guide to your coding agent, copy the prompt below and hand it over: ```text Perform an expand-and-contract migration with Prisma ORM, following https://www.prisma.io/docs/guides/database/data-migration.md. 1. In a project with a `Post` model that has a `published Boolean @default(false)` field, make sure Prisma ORM is set up (`npx prisma@latest orm init --yes --target postgres --authoring psl` if it is not), `DATABASE_URL` is in `.env`, and the current contract is applied as a migration (`npx prisma contract emit`, `npx prisma migration plan --name init`, `npx prisma db migrate`). Run `npx prisma@latest init` so the Prisma agent skills are installed, and use them. 2. Expand: add `enum Status { @@type("pg/text@1") Draft = "Draft" InProgress = "InProgress" InReview = "InReview" Published = "Published" }` and `status Status @default(Draft)` to `Post`. Keep `published`. Run `contract emit` and `migration plan --name add_status`. 3. Open the planned `migration.ts`. Above the class, add `const { sql: db, contract } = postgres({ contract: contractFromJson(endContract) });`, importing `postgres` from `@prisma/orm-postgres/runtime` and `contractFromJson` from `@prisma/orm-postgres/static`, and append a `this.dataTransform(contract, 'backfill-post-status', { check, run })` operation whose queries use `db`: `check` selects `id` from `Post` where `published = true AND status != 'Published'` with `limit(1)`, `run` updates those rows to `status = 'Published'`. Recompile with `node /migration.ts`, confirm `ops.json` contains a `data` operation, then apply with `npx prisma db migrate`. Verify with a query that every row with `published = true` now has `status = 'Published'`. 4. Update application code to read and write `status` instead of `published`. 5. Contract: remove `published` from the contract, run `contract emit`, `migration plan --name drop_published --delete Post.published`, review the destructive warning, and apply with `npx prisma db migrate`. 6. For the production database, apply only the expand migration first: `npx prisma db migrate --db "$PRODUCTION_DATABASE_URL" --to _add_status`. Deploy the code that uses `status`. The old code writes `published` only, so ask me whether writes were paused between the first command and the deploy; if they were not, stop and show me the posts whose `status` and `published` disagree, and do not run the next command until I say how to settle them. Once nothing reads or writes `published`, apply the contract migration with `npx prisma db migrate --db "$PRODUCTION_DATABASE_URL"`. Add `--show` to either command to preview the route first. Do not use `db update` against production. ``` The prompt above runs [`npx prisma@latest init`](https://www.prisma.io/docs/cli/init) in its first step. If you followed the steps by hand, run it once yourself: it installs the [Prisma ORM skills](https://www.prisma.io/docs/ai/tools/skills#available-skills-for-prisma-8) for your coding agent and keeps them matching your installed packages. Prompts you can give your agent after this guide: - "Using the prisma-8 skill, add a `dataTransform` to the latest migration that backfills `status` from `published`, recompile it, and show me the compiled SQL in ops.json." - "Plan a migration that drops the `published` column and explain the destructive warning." - "Preview what `db migrate` would run against staging and summarize the operations." ## Next steps [#next-steps] - [Editing a migration](https://www.prisma.io/docs/orm/migrations/editing-a-migration): placeholders, `rawSql`, and the recompile loop in depth. - [Applying a migration](https://www.prisma.io/docs/orm/migrations/applying-a-migration): targets, refs, and what happens when a run fails. - [Rollbacks and recovery](https://www.prisma.io/docs/orm/migrations/rollbacks-and-recovery): a rollback is one more planned migration, and a failed run is safe to retry. - [The migration graph](https://www.prisma.io/docs/orm/migrations/the-migration-graph): why two branches with migrations merge cleanly. ## Related pages - [Multiple databases](https://www.prisma.io/docs/guides/database/multiple-databases): Connect one Next.js app to two PostgreSQL databases with Prisma ORM: one contract, config, and client per database, selected with the --config flag. - [Schema management in teams](https://www.prisma.io/docs/guides/database/schema-changes): Plan, merge, and apply Prisma ORM migrations when several developers change the schema at the same time.