Posts Learn Components Snippets Categories Tags Tools 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.

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for How to Order Migrations in Laravel