On a fresh instance of MySQL 5.7.14:
schema.prisma
model Foo {
fooId String @map("foo_uuid") @default(uuid()) @id
barId String? @map("bar_uuid") @unique
}
prisma2 lift save
prisma2 lift up
Produces the following error:
Error: QueryError(QueryError(QueryError(MySqlError { ERROR 1072 (42000): Key column 'barId' doesn't exist in table }
Even just quickly looking at the error message again, I'm surprised that it's
Error: QueryError(QueryError(QueryError(MySqlError { ERROR 1072 (42000): Key column 'barId' doesn't exist in table }
Not:
Error: QueryError(QueryError(QueryError(MySqlError { ERROR 1072 (42000): Key column 'bar_uuid' doesn't exist in table }
Could this barId <> bar_uuid mapping be anything to do with it?
Maybe @map is not working, @pantharshit00 can you please help us validate this?
Ok, it does seem like it's the map which is a problem here. In the example below Foo1 and Foo2 work as expected. Foo3 does not.
I'll change the name of this Issue, hopefully should be quite a clear bug repro now.
Cheers!
datasource db {
provider = "mysql"
url = env("DB_URL")
}
generator photon {
provider = "photonjs"
output = "../../../server/src/connections/platform-db"
}
// works
model Foo1 {
fooId String @map("foo_uuid") @default(uuid()) @id
bar_uuid String? @unique
}
// works
model Foo2 {
fooId String @map("foo_uuid") @default(uuid()) @id
bar_uuid String? @map("bar_uuid") @unique
}
// doesn't work
model Foo3 {
fooId String @map("foo_uuid") @default(uuid()) @id
barId String? @map("bar_uuid") @unique
}
This is fixed in alpha and will be available today in the afternoon.
Thanks!
Most helpful comment
This is fixed in
alphaand will be available today in the afternoon.