Tyler Bell
02/08/2022, 2:10 PMmodel Plan {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
name String
description String?
status PlanStatus @default(DRAFT)
}
enum PlanStatus {
LIVE
DRAFT
}
and I want to change it to….
model Plan {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
name String
description String?
status PlanStatus @default(ACTIVE)
}
enum PlanStatus {
ACTIVE
INACTIVE
}
Essentially I want to change LIVE
-> ACTIVE
and DRAFT
-> INACTIVE
At the moment my current plan is to…
1. add ACTIVE and INACTIVE to the PlanStatus enum such that I would have.
enum PlanStatus {
ACTIVE
INACTIVE
LIVE
DRAFT
}
2. migrate DB
3. run a script that would update all LIVE values to ACTIVE and all DRAFT values to INACTIVE
4. remove LIVE and DRAFT from my schema
enum PlanStatus {
ACTIVE
INACTIVE
}
5. migrate again
I’m hoping there is a cleaner way to achieve is 🙂
Thanks!tom
02/09/2022, 1:49 PMTyler Bell
02/09/2022, 1:51 PMtom
02/09/2022, 1:51 PMdeploy
, but you need to create two migrations.Tyler Bell
02/09/2022, 1:53 PMdeploy dev
with both fields added? (assuming I would.)
Just want to make sure there’s no room for me to break anything.tom
02/09/2022, 1:53 PMdeploy
with a migration that adds both values? You will get a regular database error, unfortunatelyTyler Bell
02/09/2022, 1:55 PMprisma migrate dev
tom
02/09/2022, 1:56 PMTyler Bell
02/09/2022, 1:56 PM