Parallel Table Names using MuliSchema feature
I'm in the process of deploying some parallel models to new schemas so that we have a sandbox schema to work with until we're ready to do some data migration. I've learned that using the
multischema
feature doesn't include the schema name as part of the contraint names, so I've had to go through and use the map()
function to rename all of my contraints so that they're namespaced to my new schema (e.g. {tablename}_{column_names}_fkey
--> {schemaName}_{tablename}_{column_names}_fkey
this has allowed me to deploy the parallel tables in a new schema, however when i reun npx prisma migrate dev
i still have some outstanding changes that it's trying to apply and I can't figure out what i'm doing wrong or how to rememdy the issue. Curious if anybody has encountered issues with somethign like this
it still seems to continue to get confused with tables with the same name but in different schemas7 Replies
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into
#ask-ai
for a quick spin!Can you try running this command and see what output you get?
npx prisma migrate diff \
--from-url "$DATABASE_URL" \
--to-schema-datamodel prisma/schema.prisma \
--script > fix_migration.sql
This will generate a “diff” migration script that describes how to get from your database to the schema in
schema.prisma
Prisma CLI reference | Prisma Documentation
This page gives an overview of all available Prisma CLI commands, explains their options and shows numerous usage examples.
hey @Nurul , yes I ran that script, which is a wild output because it seems to want to drop a bunch of foreign keys and then drop a bunch of tables
would it be helpful to show you the output?
@Nurul i'm heavily using these 2 preview features, would you recommend against one of these?
previewFeatures = ["prismaSchemaFolder", "multiSchema"]
I absolutely need to use the multiSchema
, so I guess i'm mainly asking about the prismaSchemaFolder
, should i consolidate my entire schema into a single schema.prisma
file, which I would hope I wouldn't have to do.@Nurul Here is a super basic example with a single table: https://github.com/YaroBear/prisma-schema-conflict
I'll create a corresponding issue on github for this as well
GitHub
GitHub - YaroBear/prisma-schema-conflict: Simple example that illus...
Simple example that illustrates prisma migration issues with tables that share the same name in different schemas - YaroBear/prisma-schema-conflict
Github issue: https://github.com/prisma/prisma/issues/26899
GitHub
Multischema support for tables with duplicate names not working (Sq...
Bug description When working with multiple database schemas in Prisma, I encountered the following problem: Initial setup: Created a User table in the dbo schema through my first migration Second m...
Thank you for submitting the bug report and creating a reproduction repository 🙏
I'll go through the reproduction. ORM team should pick it up