PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 14, 2022

[FIXED] How does Laravel handle migrations that happen "out of order"?

 April 14, 2022     laravel, migration     No comments   

Issue

So, let's say on the first of this month, I create branch A, with a migration file named 2020_04_01_113108_modify_request_logs_table.php

But let's say I don't merge this branch into my Master branch yet, and then I start working on branch B 2 days later, with a migration file named 2020_04_03_113108_create_label_logs_table.php

So on the 4th, I merge branch B into master and run php artisan migrate, and it runs the second migration.

And then on the 6th, I'm finally ready to merge branch A into master and run php artisan migrate. Is there anything that's going to go wrong with this migration? Does the migration system care that the dates of the files happened out of order? Will it ignore the A-branch file because it's already run a migration with a date later than that file?


Solution

Migration that haven't been executed yet, will be.

To check this before hand, you can run php artisan migrate:status to see which one are already executed ('Yes') and the ones that aren't ('No').

The output will look like this:

+------+-------------------------------------------------------------------+-------+
| Ran? | Migration                                                         | Batch |
+------+-------------------------------------------------------------------+-------+
| Yes  | 2019_12_12_184629_create_users_table                              | 1     |
| Yes  | 2020_03_27_153830_create_another_table                            | 1     |
| No   | 2020_04_01_090622_modify_user_table                               |       |
| Yes  | 2020_04_11_102846_update_level                                    | 1     |
| No   | 2020_04_22_094132_dummy_migration                                 |       |
+------+-------------------------------------------------------------------+-------+


Answered By - Arnaud B
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing