Is it possible to create an Artisan call or command for
php artisan migrate
like Artisan::call('migrate);
So i can migrate missing tables to my database when connection is changed dynamically.
Config::set('database.connections.dynamicdb', array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => $database_name,
'username' => 'test_user',
'password' => '123456',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'strict' => false,
'options' => [
\PDO::ATTR_EMULATE_PREPARES => true
]
));
Artisan::call('migrate');
Or is there a way to create a command for it? Please suggest some solution.
Try this code:
\Artisan::call('migrate',
array(
'--path' => 'database/migrations',
'--database' => 'dynamicdb',
'--force' => true));
Because my default it takes /app as path and the migrations are placed in database/migrations. So this will work as it worked for me when creating new project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With