New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with migrate on SQL Server #4598
Comments
I tried reproducing this and I got a different error. I did ask me to reset the database, I answered with yes to the prompt and it threw the following:
Looks like we generate some invalid sql here for sql server |
Here is the initial migration file: -- CreateTable
CREATE TABLE [dbo].[User] (
[email] NVARCHAR(1000),
[name] NVARCHAR(1000),
[id] INT IDENTITY(1,1),
CONSTRAINT [PK__User__id] PRIMARY KEY ([id]),
CONSTRAINT [User_email_unique] UNIQUE ([email])
);
-- CreateTable
CREATE TABLE [dbo].[Post] (
[authorId] INT,
[content] NVARCHAR(1000),
[published] BIT NOT NULL,
[title] NVARCHAR(1000),
[id] INT IDENTITY(1,1),
CONSTRAINT [PK__Post__id] PRIMARY KEY ([id])
);
-- CreateTable
CREATE TABLE [dbo].[Comment] (
[id] INT IDENTITY(1,1),
[title] NVARCHAR(1000) NOT NULL,
[body] NVARCHAR(1000) NOT NULL,
[authorId] INT,
[postId] INT NOT NULL,
CONSTRAINT [PK__Comment__id] PRIMARY KEY ([id])
);
-- AddForeignKey
ALTER TABLE [dbo].[Post] ADD CONSTRAINT [FK__Post__authorId] FOREIGN KEY ([authorId]) REFERENCES [dbo].[User]([id]) ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE [dbo].[Comment] ADD CONSTRAINT [FK__Comment__postId] FOREIGN KEY ([postId]) REFERENCES [dbo].[Post]([id]) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE [dbo].[Comment] ADD CONSTRAINT [FK__Comment__authorId] FOREIGN KEY ([authorId]) REFERENCES [dbo].[User]([id]) ON DELETE SET NULL ON UPDATE CASCADE; |
Ok, I think @thebiglabasky has something weird in their setup, looking into that For @pantharshit00, and for this migration in general is it creates a cascading loop that is not allowed in SQL Server, and should be resolved in a following issue where user can describe the cascading rules per relation. |
Closing this in favor of #4580 |
Bug description
Running migrate after making changes to my schema triggered a weird issue which seems related to drift detection/shadow database.
How to reproduce
Steps to reproduce the behavior:
The schema I got from that after introspecting:
yarn prisma migrate dev --preview-feature
Expected behavior
I would have expected migrate to detect a drift and offer to reset the dev database or to successfully migrate.
Prisma information
Using custom binaries built to enable TLS to work on macOS.
Environment & setup
The text was updated successfully, but these errors were encountered: