diff --git a/core/Migrations/Version16000Date20190207141427.php b/core/Migrations/Version16000Date20190207141427.php index 1b5777a921271..74694ddbbed81 100644 --- a/core/Migrations/Version16000Date20190207141427.php +++ b/core/Migrations/Version16000Date20190207141427.php @@ -76,7 +76,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'length' => 64, ]); - $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res'); + $table->setPrimaryKey(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res'); } if (!$schema->hasTable('collres_accesscache')) { @@ -105,7 +105,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'default' => 0, ]); - $table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user'); + $table->setPrimaryKey(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user'); $table->addIndex(['user_id', 'resource_type', 'resource_id'], 'collres_user_res'); $table->addIndex(['user_id', 'collection_id'], 'collres_user_coll'); } diff --git a/core/Migrations/Version20000Date20200511105313.php b/core/Migrations/Version20000Date20200511105313.php new file mode 100644 index 0000000000000..9a816a585a17a --- /dev/null +++ b/core/Migrations/Version20000Date20200511105313.php @@ -0,0 +1,63 @@ + + * + * @author Ben Klang + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OC\Core\Migrations; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version20000Date20200511105313 extends SimpleMigrationStep { + + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if ($schema->hasTable('collres_accesscache') && !$schema->getTable('collres_accesscache')->hasPrimaryKey()) { + // Converts a unique key to a primary key for compatibility with Percona XtraDB + // See https://github.com/nextcloud/server/issues/16311 + // Step 1: Drop the old index + $schema->getTable('collres_accesscache')->dropIndex('collres_unique_user'); + } + + if ($schema->hasTable('collres_resources') && !$schema->getTable('collres_resources')->hasPrimaryKey()) { + // Converts a unique key to a primary key for compatibility with Percona XtraDB + // See https://github.com/nextcloud/server/issues/16311 + // Step 1: Drop the old index + $schema->getTable('collres_resources')->dropIndex('collres_unique_res'); + } + + return $schema; + } +} diff --git a/core/Migrations/Version20000Date20200511105314.php b/core/Migrations/Version20000Date20200511105314.php new file mode 100644 index 0000000000000..2c33c707c03b9 --- /dev/null +++ b/core/Migrations/Version20000Date20200511105314.php @@ -0,0 +1,63 @@ + + * + * @author Ben Klang + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OC\Core\Migrations; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version20000Date20200511105314 extends SimpleMigrationStep { + + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if ($schema->hasTable('collres_accesscache') && !$schema->getTable('collres_accesscache')->hasPrimaryKey()) { + // Converts a unique key to a primary key for compatibility with Percona XtraDB + // See https://github.com/nextcloud/server/issues/16311 + // Step 2: Re-create the index as a Primary Key + $schema->getTable('collres_accesscache')->setPrimaryKey(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user'); + } + + if ($schema->hasTable('collres_resources') && !$schema->getTable('collres_resources')->hasPrimaryKey()) { + // Converts a unique key to a primary key for compatibility with Percona XtraDB + // See https://github.com/nextcloud/server/issues/16311 + // Step 2: Re-create the index as a Primary Key + $schema->getTable('collres_resources')->setPrimaryKey(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res'); + } + + return $schema; + } +}