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".
$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());
}