Home / Snippets / How to Order Migrations in Laravel
How to Order Migrations in Laravel cover

How to Order Migrations in Laravel

862

3 years ago

0 comments

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".
2014_10_12_000000_create_users_table.php

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

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.
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this