migrations icon indicating copy to clipboard operation
migrations copied to clipboard

Add Reset command

Open dereuromark opened this issue 8 years ago • 8 comments

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 :)

dereuromark avatar Jun 20 '16 09:06 dereuromark

Be aware of foreign key constraints. E.g. That command would need to reset all tables? In one transaction?

htstudios avatar Jun 20 '16 09:06 htstudios

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.

dereuromark avatar Jun 20 '16 11:06 dereuromark

It should not be too hard to do.

HavokInspiration avatar Jun 20 '16 11:06 HavokInspiration

Sounds good then @dereuromark !

ionas avatar Jun 20 '16 11:06 ionas

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?

thinkingmedia avatar Jun 20 '16 15:06 thinkingmedia

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.

dereuromark avatar Oct 26 '16 23:10 dereuromark

Maybe we should open an issue at phinx first, solving it there?

dereuromark avatar Oct 07 '19 19:10 dereuromark

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".

dereuromark avatar Apr 10 '20 19:04 dereuromark