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
Cannot migrate changes on Multi Schema setup for SQL Server #24068
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/schema
Issue for team Schema.
topic: migrate
topic: multiSchema
multiple schemas
topic: sql server
Microsoft SQL Server
Comments
SevInf
added
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
team/schema
Issue for team Schema.
topic: multiSchema
multiple schemas
topic: sql server
Microsoft SQL Server
labels
May 3, 2024
Can you share the generated migration sql of |
janpio
added
bug/2-confirmed
Bug has been reproduced and confirmed.
and removed
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
topic: sql server
Microsoft SQL Server
labels
May 24, 2024
Can confirm. Initial schema: generator client {
provider = "prisma-client-js"
previewFeatures = ["multiSchema"]
}
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
// shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
schemas = ["cd", "cm", "gs", "sql", "ts"]
}
model Report {
id String @id // @unique @db.NVarChar(450)
title String
description String
chartType String? // "line" | "bar" | "pie"
certificationStatus String // "certified" | "pending" | "uncertified"
queryMapping String
// metric CertifiedMetricVersion @relation(fields: [metricId], references: [Id])
// metricId Int
// ReportVersion ReportVersion[]
@@map("Report")
@@schema("cm")
}
Creates SQL migration: BEGIN TRY
BEGIN TRAN;
-- CreateSchema
EXEC sp_executesql N'CREATE SCHEMA [cd];';;
-- CreateSchema
EXEC sp_executesql N'CREATE SCHEMA [cm];';;
-- CreateSchema
EXEC sp_executesql N'CREATE SCHEMA [gs];';;
-- CreateSchema
EXEC sp_executesql N'CREATE SCHEMA [sql];';;
-- CreateSchema
EXEC sp_executesql N'CREATE SCHEMA [ts];';;
-- CreateTable
CREATE TABLE [cm].[Report] (
[id] NVARCHAR(1000) NOT NULL,
[title] NVARCHAR(1000) NOT NULL,
[description] NVARCHAR(1000) NOT NULL,
[chartType] NVARCHAR(1000),
[certificationStatus] NVARCHAR(1000) NOT NULL,
[queryMapping] NVARCHAR(1000) NOT NULL,
CONSTRAINT [Report_pkey] PRIMARY KEY CLUSTERED ([id])
);
COMMIT TRAN;
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRAN;
END;
THROW
END CATCH Then small change to schema, make
leads to:
|
The problem is not in diffing, that works correctly when called standalone:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/schema
Issue for team Schema.
topic: migrate
topic: multiSchema
multiple schemas
topic: sql server
Microsoft SQL Server
Bug description
When trying to migrate a Schema that is mapped to the non default schema in SQL Server.
I am getting an error where the migration tries to find the table on the default schema dbo. It is not honoring the custom schema the table is placed in.
Change I am trying to migrate is make the id property unique and add the NVarChar(450)
Schema
How to reproduce
Create a schema with a custom schema in SQL Server and try migrating a change.
Expected behavior
Migration should find the right table and generate the migration scripts needed to make the migration possible.
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: