Posts Learn Snippets Categories Tags About

How to Order Migrations in Laravel

Learn how to change the order of your migrations in Laravel to get the table migrated on the preferred order

Created on Jul 05, 2021


To change the order of migrations, you can simply rename the migration file "timestamps" value.

Imagine having the "users" table with a timestamp "2014_10_12_000000".

Now you can change "2014_10_12_000000" to "2014_10_14_000000" to change the order.

Full Steps
  1. Rollback existing migration "php artisan migrate:rollback"
  2. Change the timestamps of the migration
  3. Run migration again "php artisan migrate"

The migration will be executed in ascending order of the timestamps.

Created by

PostSrc poster


Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.