Open hirokinakano opened 1 year ago
I'd accept a reset
command that does what you describe.
The same caution applies to using down
, can't really protect against operator error I'm afraid, so not sure if we need that.
@rubenv Thanks for accepting my suggestion, I will create and send you an additional PR for the reset command.
The same caution applies to using down, can't really protect against operator error I'm afraid, so not sure if we need that
It is true that the same problem can occur in the down
command and in the reset
command, which I will add this time.
Is it ok if I don't have to take that into account once in the reset command as well?
Yup, people click past any warnings anyway and anything interactive will break scripting.
TL;DR
I want to add a command that resets and redoes the application of all migration files.
For instance, it would be convenient to be able to revert all DB changes applied in the project with migration files just by executing the command like the following:
Context
There are times when I want to reset all migration files in the development or local development environment. For example, in the following cases, there are about 100 migration files, but resetting them with the redo command by specifying 100 as an argument is cumbersome.
Especially in the local development environment, the motivation to reset the migration, reapply the new migration, and rebuild the table occurs regularly. Therefore, it would be more efficient to proceed with development if it can be completed with a single operation of a command like "reset".
When executing the reset command, all tables will be dropped and all migration files under the project will be re-executed.
Caution
If you enable reset in the production environment, it is expected that accidents where all data in production is deleted could occur. Therefore, an error will be triggered when executing in the production environment. It will be necessary to add processing that allows the reset command to be executed in the production environment by passing flags or other parameters to the command.