Change Default Migrations DB Table in Config

By default, Laravel migration mechanism stores all the operations in database table migrations. Did you know that you can change it? I will show you how and why would you need it.

Imagine, you have a project and there’s another project that should be merged – like a multi-tenant, or separate blog, or something like that. But it should use the same database. How not to screw up with migrations?

This is where migrations configuration comes in. Go to file config/database.php and find this:

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */
    'migrations' => 'migrations',

So in your second project (on a sub-domain or sub-folder) you can specify a different migrations table like migrations_blog or something. And then you will be able to safely run artisan migrate command on that other project.

In general, I would encourage you to go through config folder of Laravel and check out different settings and their default values. Some of them are not mentioned in the official documentation, so might be really useful!

Like our articles?
Check out our Laravel online courses!

LEAVE A REPLY

Please enter your comment!
Please enter your name here