|
...
|
...
|
@@ -229,12 +229,8 @@ class CopyProject extends Command |
|
|
|
$tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
|
|
|
|
$tables = array_column($tables, 'Tables_in_' . $database_name);
|
|
|
|
foreach ($tables as $table) {
|
|
|
|
// 目标数据库是否存在该表
|
|
|
|
$has_table = Schema::connection('custom_mysql')->hasTable($table);
|
|
|
|
if ($has_table) {
|
|
|
|
// 1. 删除目标数据库中的表
|
|
|
|
DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}");
|
|
|
|
}
|
|
|
|
// 2. 重新创建表
|
|
|
|
$sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
|
|
|
|
DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']);
|
...
|
...
|
|