Running specific migration file in Laravel

Database Migrations in Laravel help you control your database schema through a version control file.
When a migration is created, it is named after a unique timestamp. The command php artisan migrate triggers the execution of all outstanding migrations in the exact order they were created.

If you want to run an older migration, Laravel does not give you the power to specify and execute a single one – as at the time of this writing.

If you need to run an old migration for any reason like I needed to do today, try the following steps:

Run command php artisan migrate –pretend to see all queries your migration command will run
Copy all the migration files out of the migrations folder and save them someplace safe.
Delete all migration files in the migrations folder – save for the one you want to run
You can then run the command php artisan migrate
A bit manual, but it the job for me.

Know a better way? Please share in the comments box below 🙂

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *