All skills
prisma avatar

/prisma-mongodb-upgrade

@1864519 official
by prismaprisma/skills66 stars
7

Decision and migration guide for Prisma ORM MongoDB projects on v6, which have no upgrade path to v7. Use when a MongoDB project asks about upgrading Prisma, when "upgrade to prisma 7" comes up in a project with provider = "mongodb", or when evaluating a move to Prisma 8. Triggers on "upgrade prisma mongodb", "prisma 7 mongodb", "mongodb prisma migration", "prisma 8 mongodb".

Use this Skill: https://skilld.dev/gh/prisma/skills/prisma-mongodb-upgrade

This session only. Nothing lands on disk.

referencesmigrations-mapping.md

≈907 tokens on demand. Your agent reads this file only when SKILL.md points to it.

migrations-mapping

How the v6 MongoDB "no migrations" story maps onto Prisma 8's first-class migration flow.

Priority

HIGH

Why It Matters

This is the largest workflow change in the migration — in v6, MongoDB explicitly has no Prisma Migrate, while in Prisma 8 MongoDB participates in the full migration lifecycle. Teams porting a db push habit into Prisma 8 without understanding the plan/verify/sign flow will fight the tooling or bypass its safety rails.

v6: db push only

MongoDB on v6 has no Prisma Migrate and no plans to add it — "MongoDB projects do not rely on internal schemas" (no support for Prisma Migrate). The workflow is prisma db push to sync indexes and unique constraints, with no migration history on disk.

Prisma 8: bring the existing database under management

The database already has collections and data, so bootstrap it with db update. It diffs the live database against the contract, applies the difference (strict validators, plus indexes the contract declares that v6 never created), and signs the database:

npx prisma contract emit
npx prisma db update --db "$DATABASE_URL" --dry-run
npx prisma db update --db "$DATABASE_URL" --advance-ref db

--advance-ref db records the result as the db ref that later migration plans diff from.

Do not use db init here. It only applies additive changes, and adding a validator to a collection with existing documents counts as destructive, so it refuses.

Prisma 8: every later schema change

npx prisma contract emit
npx prisma migration plan --name add_posts_indexes
npx prisma db migrate --db "$DATABASE_URL" --advance-ref db
npx prisma db verify --db "$DATABASE_URL"
  • Declare, do not hand-write: indexes and validators live in the contract, and migration plan derives the operations. Rendered MongoDB migrations import their factories (createCollection, validatedCollection, setValidation, createIndex, dropIndex, collMod, dataTransform) from @prisma/orm-mongo/target/migration.
  • Marker storage: Prisma 8 records the database's contract state in a document in the _prisma_migrations collection.
  • DDL is not transactional on MongoDB: an interrupted db migrate is resumed by running it again. After fixing anything by hand, run prisma db sign so the signature matches the database.
  • Push-style alternative: db update without a migration plan is the db push analogue for local experiments. It keeps no history.
  • Validators: Prisma 8 adds strict $jsonSchema validators to each collection by default. Once they are live, writes to documents that do not match the contract fail with Document failed validation.

Bad

Porting the v6 habit: run `db update` for every change in production, accumulating no
migration history, and hand-editing collections when verification fails.

Good

Bootstrap once with `db update --advance-ref db`. Then emit the contract, plan a migration,
apply it with `db migrate`, and check with `db verify`. Reserve plain `db update` for local
experiments, mirroring how `db push` was used on v6.

References

Source: SKILL.md on GitHub

No alerts1d3 checks · Risk SAFE
  • Gen Agent Trust Hub1d

    This skill is a safe instructional guide for migrating Prisma MongoDB projects from version 6 to Prisma Next. It contains technical reference materials and decision-making logic without any malicious code, obfuscation, or unauthorized data access patterns.

  • Socket1d

    No alerts

  • Snyk1d

    Risk: LOW · No issues

Signed by skilld at 1864519. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 3 days ago
metadata
{
  "author": "prisma",
  "version": "0.2.0"
}

README badge

README badge for prisma/skills/prisma-mongodb-upgrade