migrations
migrations copied to clipboard
Add Reset command
I would like to propose adding a
migrations reset
command which would, after confirmation, truncate the table.
This is quite useful when working with migrations at the beginning and there are lots of invalid ones already added and it is easier to just reset and mark_migrated *
afterwards to be at the step as before.
Should be easy to do - if only I knew where to hook in the command name so it can be invoked :)
Be aware of foreign key constraints. E.g. That command would need to reset all tables? In one transaction?
It wouldn't change the tables or data. Only truncating the "phinx" log table.
I was mainly looking for a migration shell way to do the opposite of mark_migrated *
etc.
Like when you want to manually re-mark the migrations as migrated.
It should not be too hard to do.
Sounds good then @dereuromark !
Resetting seems a little broad and generic. Maybe it should be something like
"migrations log clear"
That way in the future we can add more commands related to the phinx log?
Not sure if we shouldn't just go with the simple "reset" command for now, until more things come to mind it is better to keep things not too complicated.
Maybe we should open an issue at phinx first, solving it there?
Looking at Laravel, they have
migrate
migrate:fresh Drop all tables and re-run all migrations
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
migrate:status Show the status of each migration
fresh
would drop all and re-run, and reset
would do a part by part rollback.
So I guess what I proposed was more what they call "fresh".