]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not rename primary key index when renaming table
authorVincent Petry <pvince81@owncloud.com>
Tue, 17 Jun 2014 12:11:02 +0000 (14:11 +0200)
committerVincent Petry <pvince81@owncloud.com>
Tue, 17 Jun 2014 13:23:18 +0000 (15:23 +0200)
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".

lib/private/db/migrator.php

index 517be8399e86a1c4d832c5f25c45bb01f5328100..8dbfabe443ca1dcbc7e7d90c55011f7ae13b33bd 100644 (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());
                }