您可以使用:
php artisan migrate:install --database=seconddb
但你需要定义这个seconddb
连接在你的database.php
配置文件。当然运行这个命令你只会创建migrations
表,仅此而已,所以如果你想进行标准迁移,你需要使用:
php artisan migrate --database=seconddb
以及播种:
php artisan db:seed --database=seconddb
Example database.php
文件配置:
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'maindb',
'username' => 'root',
'password' => 'pass',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'seconddb' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'otherdb',
'username' => 'user',
'password' => 'otherpass',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
如果您需要有关参数的其他信息,您可以随时运行--help
参数例如:
php artisan migrate:install --help
php artisan migrate --help