Running "prisma db push" leads to migration failure

It works if I run yarn prisma db push for the first time on a new database. Run that again, I get error:
Error: ERROR: type "TriggerType" already exists
0: sql_schema_connector::apply_migration::migration_step
with step=CreateEnum(EnumId(0))
at schema-engine\connectors\sql-schema-connector\src\apply_migration.rs:28
1: sql_schema_connector::apply_migration::apply_migration
at schema-engine\connectors\sql-schema-connector\src\apply_migration.rs:11
2: schema_core::state::SchemaPush
at schema-engine\core\src\state.rs:489

error Command failed with exit code 1.
Error: ERROR: type "TriggerType" already exists
0: sql_schema_connector::apply_migration::migration_step
with step=CreateEnum(EnumId(0))
at schema-engine\connectors\sql-schema-connector\src\apply_migration.rs:28
1: sql_schema_connector::apply_migration::apply_migration
at schema-engine\connectors\sql-schema-connector\src\apply_migration.rs:11
2: schema_core::state::SchemaPush
at schema-engine\core\src\state.rs:489

error Command failed with exit code 1.
I am using multiSchema and Postgres
1 Reply
Prisma AI Help
You chose to compile with the bot. One moment while I piece together your answer… The error you're encountering is a known issue with Prisma's db push command when using the multiSchema preview feature with PostgreSQL. The error occurs because Prisma is trying to create an enum type that already exists in your database. There are a few important things to note about using multiSchema: 1. The multiSchema preview feature has limitations with migrations and introspection. As mentioned in one of the issues: "Migrate and introspection are currently not supported with multiple schemas. If you rely on them, please do not try this preview feature in the main branch of your project or in production." Github Issue #15826 2. When you run db push multiple times, Prisma attempts to recreate objects that already exist in the database, leading to errors like "type already exists" or "relation already exists". Some possible workarounds: 1. Run db push again - in some cases, running the command a second time works as noted in Github Issue #9537 2. If you're making schema changes, you might need to reset your database before pushing again 3. Consider avoiding mixing db push and migrate commands as this can cause conflicts Github Issue #7411 This is a limitation of the current implementation of the multiSchema preview feature. The Prisma team is aware of these issues and has been working on improvements, but for now, you should be cautious when using multiSchema with migrations or db push. If you need to use multiple schemas in production, you might want to consider alternative approaches until the feature is more stable. ✅ Great, thanks for letting us know that this solved your question!

Did you find this page helpful?