Rollback --target using migration name#945
Conversation
|
This will close #938. |
|
Looks like HHVM is working again of Travis. My fork of this is passing all tests, but I can't re-trigger a build for this PR. Do you think you will add this functionality change? |
| if ($found !== false) { | ||
| $version = $found; | ||
| } | ||
| } |
There was a problem hiding this comment.
You should check whether or not the version was actually found. If it was not found, throw an error. No one wants to rollback to the first migration just because they made a typo in the cli
There was a problem hiding this comment.
Nice catch. I'll update the tests and add that change in. I'm a little busy for the next few days but I'll see how I go by the weekend
There was a problem hiding this comment.
No problem, thanks for your work!
|
I didn't get much time over the weekend to look at this because I had to set up my laptop again. |
|
@jradtilbrook Try to rebase the branch on top of the current master. It should work without any issues |
|
@jradtilbrook Hey! are you still working on this? |
|
@tariquesani I still plan to but have been quite busy recently. I'm not sure when I'll be able to get some code out for you - if you're wanting something soon maybe its best for someone to take it over instead? |
ff26e8b to
332004e
Compare
|
Alright, so I finally got around to working on this. Rebasing turned out to be too hard so I started again from master. I also updated this PR to point to master as per the CONTRIBUTING doc. Hope its all fine, let me know your thoughts/intentions |
|
@jradtilbrook thanks for doing this! |
This replaces PR #939.
There is a bug where a any number less than the first migration time stamp (or a typo) supplied to the
--targetoption will cause all migrations to be rolled back. Referring to PR #939, I don't think this should be the case and optimistically the--targetoption should actually take the migration name, not the migration id (time stamp) because this functionality is basically incorporated into--date.What this pull request does is add an explicit check for
allor0passed to the--targetoption to trigger a rollback of all migrations. This doesn't allow typos or small numbers to incorrectly rollback all.Going forward, I would either prefer the
--targetfunctionality be changed to take the name, or a new option be added to specify the name. Either way, there may be an issue of non-unique migration names.