P3006 error I cannot run npx prisma migrate
this is the error
this is the prisma schema
Error: P3006
Migration `20241223102808_init` failed to apply cleanly to the shadow database.
Error code: P1014
Error:
The underlying table for model `User` does not exist.
Error: P3006
Migration `20241223102808_init` failed to apply cleanly to the shadow database.
Error code: P1014
Error:
The underlying table for model `User` does not exist.
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
phoneNumber String @id @unique
usernames String
contacts Contact[]
messagesSent Message[] @relation("SentMessages")
messagesReceived Message[] @relation("ReceivedMessages")
groups GroupMember[]
}
model Contact {
phoneNumber String
contactName String
userPhone String // reference the phoneNumber of a user
user User @relation(fields: [userPhone], references: [phoneNumber])
@@unique([userPhone, phoneNumber])
}
model Message {
MessageID String @id @default(uuid())
SenderPhone String
ReceiverPhone String
content String
timestamp DateTime @default(now())
sender User @relation("SentMessages", fields: [SenderPhone], references: [phoneNumber])
receiver User @relation("ReceivedMessages", fields: [ReceiverPhone], references: [phoneNumber])
@@index([ReceiverPhone, timestamp])
}
model Group {
groupID String @id @default(uuid())
groupName String
adminPhone String
createdDate DateTime @default(now())
members GroupMember[]
}
model GroupMember {
groupMemberID String @id @default(uuid())
groupID String
userPhone String
role String
group Group @relation(fields: [groupID], references: [groupID])
user User @relation(fields: [userPhone], references: [phoneNumber])
}
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
phoneNumber String @id @unique
usernames String
contacts Contact[]
messagesSent Message[] @relation("SentMessages")
messagesReceived Message[] @relation("ReceivedMessages")
groups GroupMember[]
}
model Contact {
phoneNumber String
contactName String
userPhone String // reference the phoneNumber of a user
user User @relation(fields: [userPhone], references: [phoneNumber])
@@unique([userPhone, phoneNumber])
}
model Message {
MessageID String @id @default(uuid())
SenderPhone String
ReceiverPhone String
content String
timestamp DateTime @default(now())
sender User @relation("SentMessages", fields: [SenderPhone], references: [phoneNumber])
receiver User @relation("ReceivedMessages", fields: [ReceiverPhone], references: [phoneNumber])
@@index([ReceiverPhone, timestamp])
}
model Group {
groupID String @id @default(uuid())
groupName String
adminPhone String
createdDate DateTime @default(now())
members GroupMember[]
}
model GroupMember {
groupMemberID String @id @default(uuid())
groupID String
userPhone String
role String
group Group @relation(fields: [groupID], references: [groupID])
user User @relation(fields: [userPhone], references: [phoneNumber])
}
3 Replies
Hey @Zerocaos12345 👋
Just to confirm, do you get this error while using Prisma Postgres?
yes
Can you please share your email id or GitHub handle that you used to sign up for Prisma Console? This would help me in checking logs for your account.