Skip to content

db update asks for confirmation when a Mongo field's validator only widens to any value #30469

Closed

Description

@wmadden-electric

What a user sees. Changing a Mongo field from Json to Bson changes its validator from the list of JSON types to {}, which admits every value that was admitted before. prisma db update still reports the change as destructive and asks the user to confirm by typing the database name (or pass --confirm <database>). The same happens for any property schema that widens to {}.

Where. isWideningSchemaChange in packages/3-mongo-target/1-mongo-target/src/core/migrations/mongo-planner.ts, which classifies any change to an existing property schema it does not recognise as destructive.

Likely fix. Teach isWideningSchemaChange that a destination schema of {} (or { bsonType: 'array', items: {} } over any array schema) admits everything the origin admitted, so the change is widening. Add planner tests for Json to Bson on a single field and a list field.

Where it came from. #30439, which introduced Bson and the typed Json validator.

Activity

  1. added a commit that references this issue on Sep 30, 2026
    4b9ba25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions