【发布时间】:2016-12-09 19:05:59
【问题描述】:
我的命令 migrate:s 包含以下内容
public function handle()
{
$sites = Sites::all();
foreach($sites as $site)
{
$host = $site->h;
$database = $site->d;
$username = $site->u;
$password = $site->p;
$this->info('Trying to migrate ' . $database);
Config::set('database.connections.mysql.host', $host);
Config::set('database.connections.mysql.database', $database);
Config::set('database.connections.mysql.username', $username);
Config::set('database.connections.mysql.password', $password);
//Reconnect with new credentials
DB::reconnect('mysql');
//Call the migration on the new connection
$this->call('migrate');
$this->info('Migrations complete for database ' . $site->d);
}
}
第一个站点总是可以很好地迁移,但是在它继续尝试创建迁移表之后,尽管已经有一个已填充的迁移表。
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'migrations' already exists
数据库的凭据是正确的,我不知道为什么它在第一次迁移后尝试创建表。
【问题讨论】:
-
您能在每个站点上查看/发布迁移表的内容吗?我想知道它是否不同步所以它认为它没有运行迁移来创建迁移表?另外,您使用的是哪个版本的 Laravel?
-
@Loren 5.1,迁移表已满,我已经删除了数据库,从全新安装开始,它总是在第一个运行。现在只是在玩,似乎由于某种原因它没有同步凭据。
标签: php database laravel database-migration laravel-artisan