Console prisma studio
Hello, when I run prisma studio locally everything is fine, but in the prisma studio console I get this error. Is it a bug in the console or on my side?
I get this error even with an empty database, I have asked AI and tried many different configs.... nothing helps
installHook.js:1 Error: {"error_code":"P1012","message":"\u001b[1;91merror\u001b[0m: \u001b[1mError validating: This line is not a valid field or attribute definition.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:57\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m56 | \u001b[0mmodel Staff {\n\u001b[1;94m57 | \u001b[0m \u001b[1;91mid Int @id(map: "Staff_pkey") @default(nextval('staff_id_seq")\u001b[0m\n\u001b[1;94m58 | \u001b[0m name String\n\u001b[1;94m | \u001b[0m\n\u001b[1;91merror\u001b[0m: \u001b[1mError validating: This line is not a valid field or attribute definition.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:67\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m66 | \u001b[0mmodel Studio {\n\u001b[1;94m67 | \u001b[0m \u001b[1;91mid Int @id(map: "Studio_pkey") @default(nextval('studio_id_seq")\u001b[0m\n\u001b[1;94m68 | \u001b[0m name String\n\u001b[1;94m | \u001b[0m\n\nValidation Error Count: 2"}
9 Replies
You decided to hold for human wisdom. We'll chime in soon! Meanwhile,
#ask-ai
is there if you need a quick second opinion.Hi @Kasmadan (UA)
Thank you for raising this. I'm taking a look at will provide updates shortly.
Hi @Kasmadan (UA)
Can you please share the relevant parts of your schema so i can reproduce using it using that given that Prisma Studion in console works fine for me at the moment.
Hi, @RaphaelEtim this is my models
model Booking {
id String @id @default(cuid())
status BookingStatus @default(CREATED)
phone String
userEmail String
staffId Int
recordId Int @unique
studioId Int
resourceId Int
servicesCount Int
seanceLength Int
startDate DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userEmail], references: [email], onDelete: Cascade)
staff Staff @relation(fields: [staffId], references: [staffId])
studio Studio @relation(fields: [studioId], references: [studioId])
@@index([id, recordId, userEmail])
}
model Staff {
id Int @id @default(autoincrement())
name String
avatar String
staffId Int @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
bookings Booking[]
@@index([id])
}
model Studio {
id Int @id @default(autoincrement())
name String
city String
country String
address String
schedule String
studioId Int @unique
latitude Float
longitude Float
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// users User[]
bookings Booking[]
@@index([id])
}
enum BookingStatus {
UPDATED
CREATED
CANCELED
}
And what I currently have in console
installHook.js:1 Error: {"error_code":"P1012","message":"\u001b[1;91merror\u001b[0m: \u001b[1mError parsing attribute "@relation": A one-to-one relation must use unique fields on the defining side. Either add an
@unique
attribute to the field staffId
, or change the relation to one-to-many.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:36\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m35 | \u001b[0m userEmail String\n\u001b[1;94m36 | \u001b[0m \u001b[1;91mstaff Staff @relation("Booking_staffId_fkey", fields: [staffId], references: [staffId], map: "Booking_staffId_fkey")\u001b[0m\n\u001b[1;94m37 | \u001b[0m staffId Int\n\u001b[1;94m | \u001b[0m\n\u001b[1;91merror\u001b[0m: \u001b[1mError parsing attribute "@relation": A one-to-one relation must use unique fields on the defining side. Either add an @unique
attribute to the field studioId
, or change the relation to one-to-many.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:39\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m38 | \u001b[0m recordId Int @unique(map: "Booking_recordId_key")\n\u001b[1;94m39 | \u001b[0m \u001b[1;91mstudio Studio @relation("Booking_studioId_fkey", fields: [studioId], references: [studioId], map: "Booking_studioId_fkey")\u001b[0m\n\u001b[1;94m40 | \u001b[0m studioId Int\n\u001b[1;94m | \u001b[0m\n\nValidation Error Count: 2"}@RaphaelEtim if you need something else I will provide
Thanks for providing more information. I’ll take a look at get back to you
@RaphaelEtim Hi, I'd like to ask about the progress :prismasmile:
Hi @Kasmadan (UA)
I appreciate your patience. I can reproduce the exact scenario you have. The record works correctly in the local studio instance but fails when used in studio on the console. I'm sharing this with the team for investigations.
@RaphaelEtim
Thanks!