Skip to content

TML-3474: Plan the rest of the data-loss statements work, and specify --convert, --backfill and MongoDB renames - #30666

Merged
wmadden-electric merged 27 commits into
mainfrom
tml-3474-remaining-slices
Oct 12, 2026
Merged

wmadden-electric merged 27 commits into
mainfrom
tml-3474-remaining-slices

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

After this work, a lossy type change is answered like this:

$ prisma migration plan --name age-to-int
✖ [CLI.CONSENT_REQUIRED] 1 subject needs a statement, and the session is not interactive.
  why: Change type of column "User"."age" would lose the data of field "User.age".
→ Pass --convert User.age
→ Pass --delete User.age

This PR plans the rest of the project that makes prisma migration plan and prisma db update refuse to lose data until the user says what each change means. It specifies the next two pieces. It changes no code.

The plan

Slice What it delivers State
1, 2 --rename; the refusal with --delete and --allow Merged
3a --convert and --backfill on Postgres and SQLite Specified here
4a Renames and deletes on MongoDB Specified here
3b The remaining SQL renames and deletes Later
4b --convert, --backfill and value object renames on MongoDB Later

3a and 4a can be built at the same time. Slices 3 and 4 were split because each was too large to review as one pull request.

Read these

Each spec opens with an example, a table of what changes for users, and the decisions to check.

Decisions to check

3a

  1. Without --backfill, migration plan fills a new required field with a temporary value ('', 0) in existing rows.
  2. alterColumnType options in migration.ts change shape. Hand-written migrations need the upgrade instructions.

4a

  1. Removing a MongoDB field is now asked about. --delete removes it from every document.
  2. MongoDB statements name fields as stored (User._id).
  3. The document rewrites are classed widening or destructive, not data, so db update can run them. This amends ADR 188.

Alternatives considered

  • Keep slices 3 and 4 whole. Neither would fit one review.
  • All of MongoDB first. Its --convert and --backfill would design those flags before the SQL slice that owns them.
  • Name MongoDB fields as written in the schema. The contract doesn't keep that name, so this would change the contract, its hashes and the client.

Agent: gauss-84

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…-change delete wording

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • projects/migration-statements/deferred.md is excluded by !projects/**
  • projects/migration-statements/slices/convert-backfill/dispatches/06-journeys-docs-fragments.md is excluded by !projects/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration
  • Configuration used: Repository: prisma/orm/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2983b98f-578e-4c03-bd39-1f06066ec0a3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

… lists

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…s, classes and variants

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…kets

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden-electric
wmadden-electric marked this pull request as ready for review October 9, 2026 07:47
@wmadden-electric
wmadden-electric requested a review from a team as a code owner October 9, 2026 07:47
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…n the plan

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…ies refusal

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…perators

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…en type

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
… rejects

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…when authoring refuses such names

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>

@wmadden wmadden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specs look good

…reported as accepting the lossy change

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…ines them

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
… hold

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…igration.ts

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…efuses the equal-hash case until then

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden-electric
wmadden-electric added this pull request to the merge queue Oct 12, 2026
Merged via the queue into main with commit b984e4a Oct 12, 2026
20 checks passed
@wmadden-electric
wmadden-electric deleted the tml-3474-remaining-slices branch October 12, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants