Skip to content

Commit 0cad072

Browse files
authored
Merge pull request #50200 from nextcloud/fix/index-systemtags
fix(systemtags): objecttype index registration
2 parents 47eedf9 + 57ffca3 commit 0cad072

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

apps/systemtags/lib/Migration/Version31000Date20241018063111.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,20 @@
1313
use Doctrine\DBAL\Types\Types;
1414
use OCP\DB\ISchemaWrapper;
1515
use OCP\Migration\Attributes\AddColumn;
16-
use OCP\Migration\Attributes\AddIndex;
1716
use OCP\Migration\Attributes\ColumnType;
18-
use OCP\Migration\Attributes\IndexType;
1917
use OCP\Migration\IOutput;
2018
use OCP\Migration\SimpleMigrationStep;
2119

2220
/**
23-
* Add objecttype index to systemtag_object_mapping
21+
* Add etag column to systemtag
2422
*/
2523
#[AddColumn(table: 'systemtag', name: 'etag', type: ColumnType::STRING, description: 'Adding etag for systemtag table to prevent conflicts')]
26-
#[AddIndex(table: 'systemtag_object_mapping', type: IndexType::INDEX, description: 'Adding objecttype index to systemtag_object_mapping')]
2724
class Version31000Date20241018063111 extends SimpleMigrationStep {
2825

2926
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
3027
/** @var ISchemaWrapper $schema */
3128
$schema = $schemaClosure();
3229

33-
if ($schema->hasTable('systemtag_object_mapping')) {
34-
$table = $schema->getTable('systemtag_object_mapping');
35-
36-
if (!$table->hasIndex('systag_objecttype')) {
37-
$table->addIndex(['objecttype'], 'systag_objecttype');
38-
}
39-
}
40-
4130
if ($schema->hasTable('systemtag')) {
4231
$table = $schema->getTable('systemtag');
4332

apps/systemtags/lib/Migration/Version31000Date20241114171300.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use OCP\Migration\SimpleMigrationStep;
1919

2020
/**
21-
* Add objecttype index to systemtag_object_mapping
21+
* Add color column to systemtag
2222
*/
2323
#[AddColumn(table: 'systemtag', name: 'color', type: ColumnType::STRING, description: 'Adding color for systemtag table')]
2424
class Version31000Date20241114171300 extends SimpleMigrationStep {

core/Application.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ public function __construct() {
235235
'systag_by_objectid',
236236
['objectid']
237237
);
238+
239+
$event->addMissingIndex(
240+
'systemtag_object_mapping',
241+
'systag_objecttype',
242+
['objecttype']
243+
);
238244
});
239245

240246
$eventDispatcher->addListener(AddMissingPrimaryKeyEvent::class, function (AddMissingPrimaryKeyEvent $event) {

core/Migrations/Version13000Date20170718121200.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
732732
$table->addIndex(['systemtagid', 'objecttype'], 'systag_by_tagid');
733733
// systag_by_objectid was added later and might be missing in older deployments
734734
$table->addIndex(['objectid'], 'systag_by_objectid');
735+
// systag_objecttype was added later and might be missing in older deployments
736+
$table->addIndex(['objecttype'], 'systag_objecttype');
735737
}
736738

737739
if (!$schema->hasTable('systemtag_group')) {

0 commit comments

Comments
 (0)