Unsupported database features (Prisma Migrate)
Prisma Migrate uses the Prisma schema to determine what features to create in the database. However, some database features cannot be represented in the Prisma schema , including but not limited to:
- Stored procedures
- Triggers
- Views
- Partial indexes
To add an unsupported feature to your database, you must customize a migration to include that feature before you apply it.
Customize a migration to include an unsupported feature
Section titled “Customize a migration to include an unsupported feature”To customize a migration to include an unsupported feature:
-
Use the
--create-onlyflag to generate a new migration without applying it:bunx prisma migrate dev --create-onlyBash pnpm prisma migrate dev --create-onlyBash yarn prisma migrate dev --create-onlyBash npx prisma migrate dev --create-only- Open the generated
migration.sqlfile and add the unsupported feature - for example, a partial index:SQL CREATE UNIQUE INDEX tests_success_constraint ON posts (subject, target) WHERE success; - Apply the migration:
- Open the generated
-
Open the generated
migration.sqlfile and add the unsupported feature - for example, a partial index:CREATE UNIQUE INDEX tests_success_constraint ON posts (subject, target) WHERE success; -
Apply the migration:
bunx prisma migrate devBash pnpm prisma migrate devBash yarn prisma migrate devBash npx prisma migrate dev- Commit the modified migration to source control.
-
Commit the modified migration to source control.