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:
Vincent Petry 2014-06-17 14:11:02 +02:00
parent 4fbab3c12d
commit 7aa11b4361
1 changed files with 7 additions and 1 deletions

View File

@ -128,7 +128,13 @@ class Migrator {
$indexes = $table->getIndexes();
$newIndexes = array();
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());
}