Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check file is loaded before trying to rollback it #19922

Merged
merged 2 commits into from
Jul 6, 2017

Conversation

dbpolito
Copy link
Contributor

@dbpolito dbpolito commented Jul 5, 2017

I have some migrations on separated folders, and i want to migrate / reset them separately...

Right now it's working great with migrate, but not for reset, when i do:

php artisan migrate --path=special/path

It works great, but when i do:

php artisan migrate:reset --path=special/path

It tries to reset all ran migrations, instead of resetting only the loaded files on special/path.

My PR fixes it, and probably won't make any difference for most use cases.


Even with my PR, there is still another known issue, if you run reset and nothing was migrated, no output is printed... This is basically because here: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Migrations/Migrator.php#L272-L280 $migrations has all ran migrations, and we do the check with loaded file later.

I think totally come with another PR properly fixing it but it will require a more code changes.

Let me know your thoughts so i can work on the other PR.

@taylorotwell taylorotwell merged commit 2cfe08e into laravel:5.4 Jul 6, 2017
@pantherdd
Copy link
Contributor

pantherdd commented Aug 5, 2017

I ran into an issue after upgrading laravel/framework from v5.4.27 to v5.4.32, and it is probably caused by this change (merged into v5.4.29).

Until now, if I tried to run php artisan migrate:rollback, and a migration file was missing (because I changed my Git branch for example), I got a nice error message telling me that rollback was impossible because of this.
Now, what happens instead is that most of the batch is rolled back (where the files are in place), but the rest is not, and I get no error at all. Everything looks fine from the output, but some migrations silently fail to run. And further migration rollbacks become impossible at this point, because the highest numbered batch is still in the database, and it never gets rolled back; you get stuck, without an explanation.

We should, at the very least, report the skipped migrations (in red?) to the user at the end of the command. Even better would be to also add a flag for users to enable this skipping behavior (disabled by default).

Is this the right place to report this? Or should I open a new Issue about it?

@devcircus
Copy link
Contributor

I would definitely recommend opening a new issue and linking this pr. Comments on a closed pr may go unnoticed for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants