Laravel 5.1 : Choose migration folder according to app config

558 views Asked by At

Basically, I want to place two different folders in app/database/migrations folder and load migrations only from one of them

 - migrations
     - folder 1
     - folder 2

And when I running the php artisan migrate I want it to look into my config/app.php and determine which files need to be executed. Is it possible?

2

There are 2 answers

1
Abdullah Al Shakib On

Yea you can migrate from specific folders. Just add --path when you run migration.

like: php artisan migrate --path='database/migrations/folder1'

0
Thanh Dao On

Not sure we can do with your Laravel version (5.1), from 5.3 Laravel supports loadMigrationsFrom method.

By adding below line to boot method from App\Providers\AppServiceProvider class, I registered custom migration path for placing all trigger definitions.

public function boot()
{
  // Other registrations

  $this->loadMigrationsFrom(database_path('migrations/triggers'));
}