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

[5.5] Fix order of run migrations #20986

Merged
merged 1 commit into from
Sep 5, 2017

Conversation

mnabialek
Copy link
Contributor

When you run migration

2016_01_01_000000_create_users_table.php

first

and then you add package to your application that has migration:

2014_01_01_000000_create_projects_table.php

and you run this, in database you should have

Migration Batch
2016_01_01_000000_create_users_table.php 1
2014_01_01_000000_create_projects_table.php 2

When you now run

php artisan migrate:rollback

because migrations are ordered by migration descending, the 2016_01_01_000000_create_users_table.php will be rolled back what could be quite surprising.

That's why the sorting order should by first by batch descending and then by migration descending to rollback migrations in the order they were run.

@paulofreitas
Copy link
Contributor

Nice finding, indeed it should be ordered by the batch number first. 👍

@taylorotwell taylorotwell merged commit 2ac4185 into laravel:5.5 Sep 5, 2017
@mnabialek mnabialek deleted the 5.5-migrations-fix branch November 5, 2017 16:59
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.

None yet

3 participants