Planetscale - New field with default(uuid) erroring out?

model Server {
***
apikey String @unique @default(uuid())
***
}
model Server {
***
apikey String @unique @default(uuid())
***
}
This is a new addition to my database, I can't seem to sync my planetscale database with this as it errors out, I also tried with @unique removed and with cuid(). Field 'apikey' doesn't have a default value (errno 1364) (sqlstate HY000) during query: insert into Server Googling error with 'planetscale' doesn't help. Thier help support has nothing either.. HELP!
Solution:
FIXED! Terrifying though, unsure if correct. I updated the database to have the apikey field. String?. ...
Jump to solution
2 Replies
Debaucus
DebaucusOP2y ago
-- The following SQL will run for this change
ALTER TABLE `Server`
ADD COLUMN `apikey` varchar(191) NOT NULL,
ADD UNIQUE KEY `Server_apikey_key` (`apikey`)
-- The following SQL will run for this change
ALTER TABLE `Server`
ADD COLUMN `apikey` varchar(191) NOT NULL,
ADD UNIQUE KEY `Server_apikey_key` (`apikey`)
This is what planetscale is telling me, but it doesn't have the default value.. why? apikey String @unique @default("") This works correctly in the schema
`apikey` varchar(191) NOT NULL DEFAULT '',
`apikey` varchar(191) NOT NULL DEFAULT '',
Solution
Debaucus
Debaucus2y ago
FIXED! Terrifying though, unsure if correct. I updated the database to have the apikey field. String?. Then added back the schema to my dev branch in preperation. Manually connected to my main db, updated existing values with raw SQL
UPDATE Server
SET apikey = UUID()
WHERE apikey IS NULL;
UPDATE Server
SET apikey = UUID()
WHERE apikey IS NULL;
Then synced the dev branch. Fixed.
Want results from more Discord servers?
Add your server