I’m running into an issue with Prisma + SQL Server when using a custom schema (not dbo)
Here’s what I’m doing:
• I’m using a custom schema called custom_schema and mapped my models with @@map or @map("custom_schema.TableName").
• I manually created the schema custom_schema in the database before running the initial migration.
• Running the initial migration with prisma migrate dev on a clean database worked fine. It created the custom_schema tables and the _prisma_migrations table, and the migration completed successfully.
• Later, when I tried to create a second migration using pnpm prisma migrate dev --name test_migration, I ran into this error:
I understand that Prisma drops and recreates the shadow database during migrate dev, and since Prisma doesn’t auto-create custom schemas in SQL Server, the custom_schema schema doesn’t exist when it tries to apply the migration to the shadow DB—hence the error.
I also tried specifying a shadowDatabaseUrl manually and pre-creating the schema there, but since the shadow DB gets wiped and recreated by Prisma anyway, that didn’t help either.
Is there an official or recommended way to use custom schemas with SQL Server in Prisma and still be able to use migrate dev reliably?
Thanks in advance for any insights 🙏
4 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!drizzle
switched once never turned back
bit more complex setup but worth it
Hey @Christopher
I believe your issue is similar to what is described in this issue:
https://github.com/prisma/prisma/issues/17574
Can you check?
GitHub
MSSQL migration failed to apply to the shadow database after creati...
Bug description We are using MSSQL for our database and are currently facing an issue with the shadow db when trying the migrate. When running prisma migrate dev a second time after creating the in...
there is no support for MSSQL
Yes thats the exact problem i am facing but i didn't manage to find a solution described in the github issue