Home > Back-end >  Change default directory for creating migration in Laravel
Change default directory for creating migration in Laravel

Time:11-04

I want to change the default directory for creating migration i.e. If I do php artisan make:migration create_users_table, it should create users table in /database/migrations/child_database. I do not want to use --path every time I create a migration for child_database. I want to change the default directory for php artisan make:migration.

CodePudding user response:

you can create your own artisan command to achieve this:

create your a new artisan command and use it to make migration in your custom directory using this article. hope help you ^_^

CodePudding user response:

try this package github repo or use laracast link

You can use loadMigrationsFrom() in your AppServiceProvider.

Inside the boot() function, run:


/**
 * Register Custom Migration Paths
 */
$this->loadMigrationsFrom([
    database_path().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR.'folder1',
    database_path().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR.'folder2',
]);/

CodePudding user response:

This question has been answered before, even though it's a little bit old it still has it's value. Have a look at: https://stackoverflow.com/a/35895106

If you use this answer, the default directory is changed and you will have the solution you want.

  • Related