|
...
|
...
|
@@ -350,19 +350,19 @@ class UpdateRoute extends Command |
|
|
|
{
|
|
|
|
$sourceTable = 'gl_route_map';
|
|
|
|
$destinationTable = 'gl_route_map_copy';
|
|
|
|
if (!Schema::hasTable($sourceTable)) {
|
|
|
|
if (!Schema::connection('custom_mysql')->hasTable($sourceTable)) {
|
|
|
|
$this->error("Source table {$sourceTable} does not exist.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (Schema::hasTable($destinationTable)) {
|
|
|
|
Schema::dropIfExists($destinationTable);
|
|
|
|
if (Schema::connection('custom_mysql')->hasTable($destinationTable)) {
|
|
|
|
Schema::connection('custom_mysql')->dropIfExists($destinationTable);
|
|
|
|
}
|
|
|
|
$columns = DB::select(DB::raw("SHOW COLUMNS FROM {$sourceTable}"));
|
|
|
|
$columns = DB::connection('custom_mysql')->select(DB::raw("SHOW COLUMNS FROM {$sourceTable}"));
|
|
|
|
$columnsDefinition = collect($columns)->map(function($column) {
|
|
|
|
return $column->Field . ' ' . $column->Type . ($column->Null === 'NO' ? ' NOT NULL' : '') . ($column->Default !== null ? " DEFAULT '" . $column->Default . "'" : '') . ($column->Extra ? ' ' . $column->Extra : '');
|
|
|
|
})->implode(', ');
|
|
|
|
DB::statement("CREATE TABLE {$destinationTable} ({$columnsDefinition})");
|
|
|
|
DB::statement("INSERT INTO {$destinationTable} SELECT * FROM {$sourceTable}");
|
|
|
|
DB::connection('custom_mysql')->statement("CREATE TABLE {$destinationTable} ({$columnsDefinition})");
|
|
|
|
DB::connection('custom_mysql')->statement("INSERT INTO {$destinationTable} SELECT * FROM {$sourceTable}");
|
|
|
|
$this->info("Table {$sourceTable} has been copied to {$destinationTable} successfully.");
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|