Return error when attempting to revert a migration if no down block is defined #363
Replies: 4 comments
-
What are you trying to achieve? If you don't define a down migration (or add a no-op statement as you propose) then I believe dbmate will still remove record of that migration but will not make any changes to the database. |
Beta Was this translation helpful? Give feedback.
-
Yes that's the problem :) If there is no Otherwise the migration is marked "pending" via the CLI and will be ran once more on I gave an example of a non idempotent command but that migration could be anything, cleanup data, changing a db design that should never be reversed, etc.. Using a division by zero does the trick for me, I just wondered if that was something handled and not documented. |
Beta Was this translation helpful? Give feedback.
-
Let's keep this issue open, I think it would be nice to explicitly fail when attempting to rollback a migration if no down migration is defined, rather than pretending that something happened. Of course, it's still entirely up to the developer to ensure that a down migration is the inverse of an up migration, and/or that the up migration is idempotent if desired. |
Beta Was this translation helpful? Give feedback.
-
I have a PR #434 where you can specify specific migrations to do or to rollback: #434. It seems like that would solve this issue? |
Beta Was this translation helpful? Give feedback.
-
Hello,
Is there a way to ensure no rollback ever occurs. I tried removing the
migrate:down
keyword but rolling back then succeeds, which I don't wantFor the moment, this seems to do the trick. Do you see a better way?
Beta Was this translation helpful? Give feedback.
All reactions