Do not rename primary key index when renaming table
When the migrator renames a table, for example for upgrade simulation, it should not rename the primary key to avoid messing up with the diff because the MySQL Doctrine code expects that index to always be called "primary".
This commit is contained in:
parent
4fbab3c12d
commit
7aa11b4361
|
@ -128,7 +128,13 @@ class Migrator {
|
||||||
$indexes = $table->getIndexes();
|
$indexes = $table->getIndexes();
|
||||||
$newIndexes = array();
|
$newIndexes = array();
|
||||||
foreach ($indexes as $index) {
|
foreach ($indexes as $index) {
|
||||||
$indexName = 'oc_' . uniqid(); // avoid conflicts in index names
|
if ($index->isPrimary()) {
|
||||||
|
// do not rename primary key
|
||||||
|
$indexName = $index->getName();
|
||||||
|
} else {
|
||||||
|
// avoid conflicts in index names
|
||||||
|
$indexName = 'oc_' . uniqid();
|
||||||
|
}
|
||||||
$newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary());
|
$newIndexes[] = new Index($indexName, $index->getColumns(), $index->isUnique(), $index->isPrimary());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue