P
Prisma8mo ago
LEGION

Prisma new field adding will thorw the unkown error

model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
hashedPassword String
username String @unique
image String
termsAccepted Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
isVerified Boolean @default(false)
verifyOTP String @default("")
resetOTP String @default("")
role Role @default(USER)
invoices Invoices[]
userPlans UserPlans @relation(fields: [userPlansId], references: [id])
userPlansId String @db.ObjectId
userIPv6Plans IPv6Plans[]
}

model UserPlans {
id String @id @default(auto()) @map("_id") @db.ObjectId
// customer plan fields
residential Boolean @default(false)
datacenter_shared Boolean @default(false)
datacenter_unmetered Boolean @default(false)
ipv6 Boolean @default(false)
mobile_proxies Boolean @default(false)
User User[]
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
hashedPassword String
username String @unique
image String
termsAccepted Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
isVerified Boolean @default(false)
verifyOTP String @default("")
resetOTP String @default("")
role Role @default(USER)
invoices Invoices[]
userPlans UserPlans @relation(fields: [userPlansId], references: [id])
userPlansId String @db.ObjectId
userIPv6Plans IPv6Plans[]
}

model UserPlans {
id String @id @default(auto()) @map("_id") @db.ObjectId
// customer plan fields
residential Boolean @default(false)
datacenter_shared Boolean @default(false)
datacenter_unmetered Boolean @default(false)
ipv6 Boolean @default(false)
mobile_proxies Boolean @default(false)
User User[]
}
i have this prisma schema and my situation is i want userPlans to be unique to all users and i want to return default values if userPlans dont exists for old users and i dont want to excute any js
14 Replies
LEGION
LEGIONOP8mo ago
Any help
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
LEGION
LEGIONOP8mo ago
Naming conventions isnt issue here
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
LEGION
LEGIONOP8mo ago
Its getting added automatically When i press save Even if i remove it its getting added automatically My only problem is my old users dont have this object And its returning errorr for them I want to return default values
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
LEGION
LEGIONOP8mo ago
Can you explain this more
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
LEGION
LEGIONOP8mo ago
I do
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
LEGION
LEGIONOP8mo ago
Cant it be done via prisma? Even if i do set field it will only set single field What about relation?
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
LEGION
LEGIONOP8mo ago
I can generate a sample data using schema put it in chatgpt it will give a random data
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server