|
...
|
...
|
@@ -104,17 +104,16 @@ class Demo extends Command |
|
|
|
public function handle(){
|
|
|
|
return $this->initTable(1380,1862);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function initTable($project_id, $news_project_id)
|
|
|
|
{
|
|
|
|
config(['database.connections.custom_tmp_mysql_copy.database' => 'gl_data_' . $project_id]);
|
|
|
|
$database_name = DB::connection('custom_tmp_mysql_copy')->getDatabaseName();
|
|
|
|
$tables = Schema::connection('custom_tmp_mysql_copy')->getAllTables();
|
|
|
|
$tables = array_column($tables, 'Tables_in_' . $database_name);
|
|
|
|
|
|
|
|
foreach ($tables as $table) {
|
|
|
|
config(['database.connections.custom_mysql.database' => 'gl_data_' . $news_project_id]);
|
|
|
|
$has_table = Schema::connection('custom_mysql')->hasTable($table);
|
|
|
|
|
|
|
|
if (!$has_table) {
|
|
|
|
$sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE {$table}");
|
|
|
|
DB::connection('custom_mysql')->statement(array_values((array)$sql[0])[0]); // 修正此处的sql语句获取方式
|
...
|
...
|
|