Replies: 1 comment
-
Migrations are not designed to preserve data bidirectionally. You only ever use the "up" migrations in production. "down" migrations are provided only to reset the database to the beginning state, like for testing. Data migrations are provided as queries just like schema migrations. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have read
Mojo::Pg::Migrations
but I still do not understand how a migration should work.The migration can be done with SQL scripts used by the function
from_dir
. Each version of the schema has an "up" script to set up the schema and a "down" script to drop the schema. This may work fine for the schema but how about the data?A migration must also update the data. The old data matching the old schema must be preserved and after the new schema has been installed, the old data needs to be imported. And additional data has to be added for any columns added by the new version of the schema. I do not understand how this should work with just an "up" and a "down" script. When the down script of schema version 1 drops the schema, all data is lost.
What is the idea behind these "up" and "down" scripts? And which one should migrate the data?
Beta Was this translation helpful? Give feedback.
All reactions