Zerocaos12345
Zerocaos12345
PPrisma
Created by Zerocaos12345 on 12/30/2024 in #help-and-questions
P3006 error I cannot run npx prisma migrate
this is the error
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.
this is the prisma schema
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])
}
5 replies