Hello guys! It is possible with prisma to rollback...
# orm-help
j
Hello guys! It is possible with prisma to rollback to the previous migration? Like, if i added a new column by mistake, then i can say that i want to rollback to the last migration, or a to a migration ID. Thanks!
j
undo the commit, and deploy again?
j
but, at certain point i will have an impossible deploy, because of the data that is needed, and prisma don't have default values for required fields.
if prisma had some functionality like this (a migration rollback) i think it works out of the box
it has?
j
with any destructive migration, you are going to have to evaluate weather or not the deleted data is important. Sometimes just going in the playground and manually deleting some data is enogh to make the deploy safe
j
yeap, but even setting a default value for a required field, the deploy cannot be done
and i don't want to manually do stuff
that destroys the workflow
j
prisma deploy --force
and see what the damage is
try locally first
also
prisma deploy --dry-run
to see whats going to happen
j
You are creating a required field but there are already nodes present that would violate that constraint.
even with force
fieldExample: String! @default(value: "EXAMPLE")
why don't prisma just set the field with the default value when deploying?
do i really need to make the field not required, then set the data for all rows, and then deploy again with the required?
j
It depends what you are aiming for. running an updateall mutation might do the trick
sorry, the syntax is
updateManyUsers
j
i expected to do it without programming, only editing the schema
i think it's kind of the main purpose here, to be easy
j
¯\_(ツ)_/¯
j
i change the schema, make it required, set a default value, and it just works
hm
but i seems that it isn't like that
but thanks anyway 🙂
j
some migrations need a little help
t
Tis the reason they are working on a much more robust migrations solution: https://github.com/prisma/rfcs/blob/migrations/text/0000-migrations.md
Couple of the proposed commands:
Copy code
prisma migrate rollback
prisma migrate rollback --pending