Title
j

José Gomes

05/02/2019, 5:38 PM
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

Jared

05/02/2019, 5:43 PM
undo the commit, and deploy again?
j

José Gomes

05/02/2019, 5:50 PM
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

Jared

05/02/2019, 5:57 PM
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

José Gomes

05/02/2019, 5:59 PM
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

Jared

05/02/2019, 5:59 PM
prisma deploy --force
and see what the damage is
try locally first
also
prisma deploy --dry-run
to see whats going to happen
j

José Gomes

05/02/2019, 6:00 PM
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

Jared

05/02/2019, 6:02 PM
It depends what you are aiming for. running an updateall mutation might do the trick
sorry, the syntax is
updateManyUsers
j

José Gomes

05/02/2019, 6:06 PM
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

Jared

05/02/2019, 6:07 PM
¯\_(ツ)_/¯
j

José Gomes

05/02/2019, 6:07 PM
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

Jared

05/02/2019, 6:08 PM
some migrations need a little help
t

tmoney

05/02/2019, 7:04 PM
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:
prisma migrate rollback
prisma migrate rollback --pending