-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Unable to introspect a certain database schema when combined with others using multiSchema
feature
#19677
Comments
Is there anything weird or unexpected about the |
Nothing weird about the |
There is no "what the heck!?" reaction emoji, so I am making it explicit by posting a comment. |
+1 Can confirm the exact same scenario. I had key links between schemas and had to delete them all before db pull would work. But even then I had to pull schemas individually and copy and paste because even though they were in the schemas array they wouldn't show up |
have the same error
it takes only NSI schema
|
I'm experiencing a similar issue with this datasource:
Models for all the schemas except |
I have exactly the same problem. Not solved yet?
|
I am also having this issue when doing an |
Same issue here, when npx prisma db pull one by one without multiSchema it works but when adding previewFeatures = ["multiSchema"] and an array of databases then the npx prisma db pull fails with Error: |
You don't even need special SQL in this case, I managed to reproduce this by just:
generator client {
provider = "prisma-client-js"
previewFeatures = ["multiSchema"]
}
generator prismaClassGenerator {
provider = "prisma-class-generator"
output = "../libs/database/src/prisma-class"
separateRelationFields = "true"
dryRun = "false"
}
datasource db {
provider = "sqlserver"
url = env("TEST_MSSQL_JDBC_URI")
schemas = ["Appointments", "Trips", "core"]
}
model Associations {
AppointmentID BigInt
AssociatedAppointmentID BigInt
AssociationTypeID Int @db.SmallInt
Priority Int @db.SmallInt
@@id([AppointmentID, AssociatedAppointmentID], map: "PK_Associations")
@@schema("Appointments")
}
model AssociationTypes {
ID Int @id(map: "PK_AssociationTypes") @default(autoincrement()) @db.SmallInt
Name String @db.NVarChar(50)
@@schema("Appointments")
}
model billCodes {
Id BigInt @id(map: "PK_AppointmentBillCode") @default(autoincrement())
HayesId String? @db.NVarChar(128)
Article String? @db.NVarChar(128)
Description String? @db.NVarChar(128)
SP_ProjectType String? @db.NVarChar(20)
LTLallowed Boolean @default(false, map: "DF_AppointmentBillCode_LTLallowed")
FTLallowed Boolean @default(false, map: "DF_AppointmentBillCode_FTLallowed")
CustomerID Int? @db.SmallInt
@@schema("Appointments")
}
model ChargeTypes {
ID Int @id(map: "PK_ChargeTypes") @default(autoincrement()) @db.TinyInt
Name String @db.NVarChar(50)
BOL_Description String? @db.NVarChar(128)
rv Unsupported("timestamp") @map("_rv")
@@schema("Appointments")
}
model Clusters {
ID Int @id(map: "PK_Clusters") @default(autoincrement())
Name String @db.NVarChar(128)
TenantID Int
Sites Sites[]
@@schema("core")
}
model Containers {
ID Int @id(map: "PK_Containers") @default(autoincrement()) @db.SmallInt
TenantID Int
Description String @db.NVarChar(100)
Width Int
Length Int
Units String @db.NVarChar(10)
Area Int?
@@schema("core")
}
model Documents {
ID BigInt @id(map: "PK_AppointmentBOLs") @default(autoincrement())
DocumentTypeID Int @default(1, map: "DF_AppointmentBOLs_DocumentTypeID") @db.SmallInt
ApptID BigInt
Name String @db.NVarChar(256)
Path String? @db.NVarChar(Max)
CreationDate DateTime @db.SmallDateTime
CreatedByUserID Int
TemplateVersion Int?
rv Unsupported("timestamp") @map("_rv")
WebPath String? @db.NVarChar(Max)
SsrsUrl String? @db.NVarChar(Max)
FilePath String @db.NVarChar(Max)
@@index([DocumentTypeID, ApptID], map: "<Name of Missing Index, sysname,>")
@@schema("Appointments")
}
model DocumentTypes {
ID Int @id(map: "PK_DocumentTypes_1") @default(autoincrement()) @db.SmallInt
Name String @db.NVarChar(128)
Report String? @db.NVarChar(128)
rv Unsupported("timestamp") @map("_rv")
Inbound Boolean?
Outbound Boolean?
Limit Int?
@@schema("Appointments")
}
model ItineraryTypes {
ID Int @id(map: "PK_ItineraryTypes") @default(autoincrement()) @db.SmallInt
Name String @db.NVarChar(50)
@@schema("Appointments")
}
model Queues {
Id BigInt @id(map: "PK_Queues") @default(autoincrement())
SiteID BigInt?
QueueTypeID Int? @db.TinyInt
Location String? @unique(map: "IX_Locations") @db.NVarChar(128)
Name String? @db.NVarChar(128)
Direction String? @db.VarChar(6)
Active Boolean?
rv Unsupported("timestamp") @map("_rv")
Export Boolean?
@@schema("Appointments")
}
model QueueTypes {
ID Int @id(map: "PK_QueueTypes") @default(autoincrement()) @db.TinyInt
Name String @db.NVarChar(50)
Description String? @db.NVarChar(128)
rv Unsupported("timestamp") @map("_rv")
@@schema("Appointments")
}
model Settings {
ID Int @id(map: "PK_Settings") @default(autoincrement())
Name String @db.NVarChar(255)
Value String? @db.NVarChar(Max)
Notes String? @db.NVarChar(Max)
rv Unsupported("timestamp") @map("_rv")
@@schema("Appointments")
}
model Settings_Overrides {
ID Int @id(map: "PK_Settings_Override") @default(autoincrement())
SettingID Int
Active Boolean
TenantID Int? @db.SmallInt
SiteID Int? @db.SmallInt
CustomerID Int? @db.SmallInt
QueueID Int? @db.SmallInt
Direction String? @db.NVarChar(10)
LiveLoad Boolean?
PreviousApptStatusID Int? @db.SmallInt
ApptStatusID Int? @db.SmallInt
Value String @db.NVarChar(Max)
@@schema("Appointments")
}
model Sites {
ID BigInt @id(map: "PK_Sites") @default(autoincrement())
Name String? @db.NVarChar(128)
StreetAddress String? @db.NVarChar(128)
City String? @db.NVarChar(128)
State String? @db.NVarChar(128)
PostalCode String? @db.NVarChar(15)
WMShipPoint String? @db.NVarChar(20)
LTLout Boolean @default(false, map: "DF_Sites_LTLout")
rv Unsupported("timestamp") @map("_rv")
SiteName String? @db.NVarChar(128)
TenantID Int?
ParentID Int?
Code String? @db.NVarChar(10)
Active Boolean?
WhseNumber String? @db.NVarChar(50)
TimeZone String? @db.NVarChar(50)
TZ String? @db.NVarChar(10)
ClusterID Int?
Clusters Clusters? @relation(fields: [ClusterID], references: [ID], onUpdate: NoAction, map: "FK_Sites_Clusters")
@@schema("core")
}
model statuses {
ID Int @id(map: "PK_AppointmentStatuses") @default(autoincrement()) @db.SmallInt
Name String? @db.NVarChar(50)
Status Int?
Description String @db.NVarChar(51)
DockDoorRequired Boolean @default(false, map: "DF_AppointmentStatuses_DockDoorRequred")
DockTypeID Int? @db.SmallInt
@@schema("Appointments")
}
model Trips {
ID BigInt @id(map: "PK_Trips") @default(autoincrement())
TripTypeID Int
TripName String @db.NVarChar(120)
TripTypes TripTypes @relation(fields: [TripTypeID], references: [ID], onUpdate: NoAction, map: "FK_Trips_TripTypes")
@@schema("Trips")
}
model TripTypes {
ID Int @id(map: "PK_TripTypes") @default(autoincrement())
Name String @db.NVarChar(128)
TenantID Int
Trips Trips[]
@@schema("Trips")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["multiSchema"]
}
generator prismaClassGenerator {
provider = "prisma-class-generator"
output = "../libs/database/src/prisma-class"
separateRelationFields = "true"
dryRun = "false"
}
datasource db {
provider = "sqlserver"
url = env("TEST_MSSQL_JDBC_URI")
schemas = ["Appointments", "Trips", "core"]
}
When there should definitely be 17 models |
Which models are missing @Druue? Are those across all schemas, or only specific ones? |
@Druue does one of the missing schemas happen to be "Settings_Overrides"? I seem to have issues with snake-cased schemas. |
I seem to have forgotten one of the models from the Only models from the
Neither of which are snake-case, nor are any of the schemas |
Same issue here with SQL Server. I have a couple of cross schema references and can't not include all schemas |
Bug description
When I use
prisma db pull
to introspect my sql server database using themultiSchema
feature, I am unable to combine theTrips
database schema with any of my other schemas. When I list theTrips
schema by itself, I am able to introspect it correctly, but when I combine it with other schemas and runprisma db pull
again, it removes the introspected models from theTrips
schema.How to reproduce
multiSchema
preview feature as outlined here https://www.prisma.io/docs/guides/other/multi-schemadb
datasource inschema.prisma
file to include multiple schemas includingTrips
prisma db pull
to introspect the databaseTrips
database schemadb
datasource to only include theTrips
schemaprisma db pull --force
to introspect the database again and clear out the previous modelsTrips
database schemaExpected behavior
The
Trips
database schema should be successfully introspected along with any combination of other valid database schemas.Prisma information
When introspecting other schemas along with
Trips
:When introspecting only
Trips
schema:Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: