question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Sql Azure] migrate gets stuck without a shadow DB

See original GitHub issue

Bug description

When I use prisma migrate with SQL Azure, the command gets stuck.

image

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.

image

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:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
pantharshit00commented, Apr 13, 2021

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.

1reaction
tomhoulecommented, May 31, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found