Fix temporary schema creation
This commit is contained in:
parent
58c61c8336
commit
be80dce585
|
@ -47,8 +47,12 @@ class Migrator {
|
||||||
$existingTables = $this->connection->getSchemaManager()->listTableNames();
|
$existingTables = $this->connection->getSchemaManager()->listTableNames();
|
||||||
|
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
|
if (strpos($table->getName(), '.')) {
|
||||||
|
list(, $tableName) = explode('.', $table->getName());
|
||||||
|
} else {
|
||||||
|
$tableName = $table->getName();
|
||||||
|
}
|
||||||
// don't need to check for new tables
|
// don't need to check for new tables
|
||||||
list(, $tableName) = explode('.', $table->getName());
|
|
||||||
if (array_search($tableName, $existingTables) !== false) {
|
if (array_search($tableName, $existingTables) !== false) {
|
||||||
$this->checkTableMigrate($table);
|
$this->checkTableMigrate($table);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +67,7 @@ class Migrator {
|
||||||
*/
|
*/
|
||||||
protected function checkTableMigrate(Table $table) {
|
protected function checkTableMigrate(Table $table) {
|
||||||
$name = $table->getName();
|
$name = $table->getName();
|
||||||
$tmpName = uniqid();
|
$tmpName = 'oc_' . uniqid();
|
||||||
|
|
||||||
$this->copyTable($name, $tmpName);
|
$this->copyTable($name, $tmpName);
|
||||||
|
|
||||||
|
@ -94,12 +98,12 @@ class Migrator {
|
||||||
$indexes = $table->getIndexes();
|
$indexes = $table->getIndexes();
|
||||||
$newIndexes = array();
|
$newIndexes = array();
|
||||||
foreach ($indexes as $index) {
|
foreach ($indexes as $index) {
|
||||||
$indexName = uniqid(); // avoid conflicts in index names
|
$indexName = 'oc_' . uniqid(); // avoid conflicts in index names
|
||||||
$newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary());
|
$newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary());
|
||||||
}
|
}
|
||||||
|
|
||||||
// foreign keys are not supported so we just set it to an empty array
|
// foreign keys are not supported so we just set it to an empty array
|
||||||
return new Table($newName, $table->getColumns(), $indexes, array(), 0, $table->getOptions());
|
return new Table($newName, $table->getColumns(), $newIndexes, array(), 0, $table->getOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue