laravellaravel-migrations

Running one specific Laravel migration (single file)


I have 5 migrations in my project. I only want to run one of these migrations. Is it possible to pass the name of a single file to the php artisan migrate command?


Solution

  • Looks like you're doing it wrong.

    Migrations were made to be executed by Laravel one by one, in the exact order they were created, so it can keep track of execution and order of execution. That way Laravel will be able to SAFELY rollback a batch of migrations, without risking breaking your database.

    Giving the user the power to execute them manually, make it impossible to know (for sure) how to rollback changes in your database.

    If your really need to execute something in your database, you better create a DDL script and manually execute it on your webserver.

    Or just create a new migration and execute it using artisan.

    EDIT:

    If you need to run it first, you need to create it first.

    If you just need to reorder them, rename the file to be the first. Migrations are created with a timestemp:

    2013_01_20_221554_table
    

    To create a new migration before this one you can name it

    2013_01_19_221554_myFirstMigration