Created
June 17, 2019 06:48
-
-
Save hasnhasan/ce46d0f7691809f4bbf48e6aae489da7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->info('--Aktarım Başladı-'); | |
$connectionName = 'old_mysql'; | |
$newDb = \DB::connection(''); | |
$oldDb = \DB::connection($connectionName); | |
$tmpOldTables = $oldDb->getDoctrineSchemaManager()->listTables(); | |
$tables = $newDb->getDoctrineSchemaManager()->listTables(); | |
$newTables = []; | |
$foreignKeys = []; | |
$indexes = []; | |
foreach ($tables as $table) { | |
if (!isset($newTables[$table->getName()])) { | |
$newTables[$table->getName()] = []; | |
} | |
$foreignKeys[$table->getName()] = $table->getForeignKeys(); | |
$indexes[$table->getName()] = $table->getIndexes(); | |
foreach ($table->getColumns() as $column) { | |
$newTables[$table->getName()][$column->getName()] = $column; | |
} | |
} | |
$oldTables = []; | |
foreach ($tmpOldTables as $table) { | |
#Eski db de migrations tablosunu sil | |
if ($table->getName() == 'migrations') { | |
$oldDb->select('DROP TABLE migrations'); | |
} | |
if (!isset($oldTables[$table->getName()])) { | |
$oldTables[$table->getName()] = []; | |
} | |
foreach ($table->getColumns() as $column) { | |
$oldTables[$table->getName()][$column->getName()] = $column; | |
} | |
} | |
$oldTableNameList = $oldDb->getDoctrineSchemaManager()->listTableNames(); | |
$tableNameList = $newDb->getDoctrineSchemaManager()->listTableNames(); | |
$createTables = array_diff($tableNameList, $oldTableNameList); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment