[Sql Azure] migrate gets stuck without a shadow DB
See original GitHub issueBug description
When I use prisma migrate with SQL Azure, the command gets stuck.
It also tries to create a database on SQL Azure, which might cause all sorts of issues (including billing) for people that don’t know what’s going on.
How to reproduce
npx prisma migrate dev --name init
Expected behavior
A migration is created and applied. If there’s an error, I should see a clear message on what went wrong.
Fix
In order to fix this, one has to use the Shadow Database configuration to make it work.
Prisma information
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["microsoftSqlServer"]
}
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
}
Environment & setup
Environment variables loaded from .env
prisma : 2.20.1
@prisma/client : 2.20.1
Current platform : darwin
Query Engine : query-engine 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine : migration-engine-cli 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 60ba6551f29b17d7d6ce479e5733c70d9c00860e
Studio : 0.365.0
Preview Features : microsoftSqlServer
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Prisma Migrate: Error creating shadow database #4571 - GitHub
This happens because Migrate tries to create a shadow database under the hood. Some of the situations where this might be the case:...
Read more >Common issues - Azure Database Migration Service
Learn about how to troubleshoot common known issues/errors associated with using Azure Database Migration Service.
Read more >Error when migrating models to database Prisma
My database is postgresQL and it's hosted on heroku. My DATABASE_URL is copied/pasted from the configs on heroku. Here are my .json dependencies ......
Read more >Azure SQL Data Migration Assistant is Stuck on "Migrate Data"
Dma.exe Information: 0 : 'Exception type: System.IO.IOException Message: There is not enough space on the disk. It seems like the workstation ...
Read more >About the shadow database - Prisma
Note: The shadow database is not responsible for checking if a migration file ... Note: The automatic creation of shadow databases is disabled...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I wasn’t able to reproduce it getting stuck but yes creating new database without consent on azure is a problem as you are billed per database, not the by database server on azure.
I think we can add a warning for azure which will warn the user about this. We can do this my check for
windows.net
in the hostname.@luisrudge I went with your suggestion of checking the host in this PR: https://github.com/prisma/prisma-engines/pull/1964 — it’s a small change so it will probably make it in tomorrow’s release, and it can then be tested in the field. We should still investigate why prisma gets stuck on Azure SQL, but it’s probably a bit harder to fix.