diff options
author | Joas Schilling <coding@schilljs.com> | 2020-11-10 09:34:57 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-11-10 15:36:27 +0100 |
commit | d5df033ede1f2b19b87c365b1f808130023edf17 (patch) | |
tree | d00503789c2e1188d59726e221dd9445e858f784 /apps | |
parent | 5b5aebbf66e7559aac73eb82b236b052b6a1ae3e (diff) | |
download | nextcloud-server-d5df033ede1f2b19b87c365b1f808130023edf17.tar.gz nextcloud-server-d5df033ede1f2b19b87c365b1f808130023edf17.zip |
Create primary keys on all tables and add a command to create the afterwards
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
3 files changed, 18 insertions, 1 deletions
diff --git a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php index 53348d8f86d..bf0d0f8eecd 100644 --- a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php +++ b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php @@ -52,7 +52,8 @@ class Version1010Date20200630191755 extends SimpleMigrationStep { 'notnull' => true, 'length' => 4, ]); - $table->addUniqueIndex(['share_id'], 'share_id_index'); + $table->setPrimaryKey(['share_id'], 'federated_res_pk'); +// $table->addUniqueIndex(['share_id'], 'share_id_index'); } return $schema; } diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 0f9dd84febb..6984b0f5aea 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -49,6 +49,7 @@ use OC\AppFramework\Http; use OC\DB\Connection; use OC\DB\MissingColumnInformation; use OC\DB\MissingIndexInformation; +use OC\DB\MissingPrimaryKeyInformation; use OC\DB\SchemaWrapper; use OC\IntegrityCheck\Checker; use OC\Lock\NoopLockingProvider; @@ -452,6 +453,15 @@ Raw output return $indexInfo->getListOfMissingIndexes(); } + protected function hasMissingPrimaryKeys(): array { + $info = new MissingPrimaryKeyInformation(); + // Dispatch event so apps can also hint for pending index updates if needed + $event = new GenericEvent($info); + $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, $event); + + return $info->getListOfMissingPrimaryKeys(); + } + protected function hasMissingColumns(): array { $indexInfo = new MissingColumnInformation(); // Dispatch event so apps can also hint for pending index updates if needed @@ -722,6 +732,7 @@ Raw output 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), + 'missingPrimaryKeys' => $this->hasMissingPrimaryKeys(), 'missingIndexes' => $this->hasMissingIndexes(), 'missingColumns' => $this->hasMissingColumns(), 'isSqliteUsed' => $this->isSqliteUsed(), diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index dbc3fc7d0db..43ec984041c 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -165,6 +165,7 @@ class CheckSetupControllerTest extends TestCase { 'isOpcacheProperlySetup', 'hasFreeTypeSupport', 'hasMissingIndexes', + 'hasMissingPrimaryKeys', 'isSqliteUsed', 'isPHPMailerUsed', 'hasOpcacheLoaded', @@ -449,6 +450,9 @@ class CheckSetupControllerTest extends TestCase { ->method('hasMissingIndexes') ->willReturn([]); $this->checkSetupController + ->method('hasMissingPrimaryKeys') + ->willReturn([]); + $this->checkSetupController ->method('isSqliteUsed') ->willReturn(false); $this->checkSetupController @@ -587,6 +591,7 @@ class CheckSetupControllerTest extends TestCase { 'isSqliteUsed' => false, 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion', 'missingIndexes' => [], + 'missingPrimaryKeys' => [], 'missingColumns' => [], 'isMemoryLimitSufficient' => true, 'appDirsWithDifferentOwner' => [], |