Skip to content

Commit 838b02c

Browse files
committed
Create primary keys on all tables
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent ccdcc5e commit 838b02c

9 files changed

Lines changed: 178 additions & 9 deletions

apps/federatedfilesharing/appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>Federated file sharing</name>
66
<summary>Provide federated file sharing across servers</summary>
77
<description>Provide federated file sharing across servers</description>
8-
<version>1.11.0</version>
8+
<version>1.11.1</version>
99
<licence>agpl</licence>
1010
<author>Bjoern Schiessle</author>
1111
<author>Roeland Jago Douma</author>

apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
5252
'notnull' => true,
5353
'length' => 4,
5454
]);
55-
$table->addUniqueIndex(['share_id'], 'share_id_index');
55+
$table->setPrimaryKey(['share_id'], 'federated_res_pk');
56+
// $table->addUniqueIndex(['share_id'], 'share_id_index');
5657
}
5758
return $schema;
5859
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
6+
*
7+
* @author Joas Schilling <coding@schilljs.com>
8+
*
9+
* @license GNU AGPL version 3 or any later version
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Affero General Public License as
13+
* published by the Free Software Foundation, either version 3 of the
14+
* License, or (at your option) any later version.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
*/
25+
26+
namespace OCA\FederatedFileSharing\Migration;
27+
28+
use Closure;
29+
use OCP\DB\ISchemaWrapper;
30+
use OCP\Migration\IOutput;
31+
use OCP\Migration\SimpleMigrationStep;
32+
33+
/**
34+
* Auto-generated migration step: Please modify to your needs!
35+
*/
36+
class Version1010Date20201110084037 extends SimpleMigrationStep {
37+
/**
38+
* @param IOutput $output
39+
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
40+
* @param array $options
41+
* @return null|ISchemaWrapper
42+
*/
43+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
44+
/** @var ISchemaWrapper $schema */
45+
$schema = $schemaClosure();
46+
$updated = false;
47+
48+
if ($schema->hasTable('federated_reshares')) {
49+
$table = $schema->getTable('federated_reshares');
50+
if (!$table->hasPrimaryKey()) {
51+
$table->setPrimaryKey(['share_id'], 'federated_res_pk');
52+
if ($table->hasIndex('share_id_index')) {
53+
$table->dropIndex('share_id_index');
54+
}
55+
$updated = true;
56+
}
57+
}
58+
59+
return $updated ? $schema : null;
60+
}
61+
}

core/Migrations/Version13000Date20170718121200.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,8 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
673673
'default' => 0,
674674
'unsigned' => true,
675675
]);
676-
$table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
676+
$table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk');
677+
// $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
677678
}
678679

679680
if (!$schema->hasTable('systemtag_group')) {
@@ -808,7 +809,8 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
808809
'default' => '',
809810
]);
810811
$table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index');
811-
$table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
812+
$table->setPrimaryKey(['user_id', 'object_type', 'object_id'], 'crm_pk');
813+
// $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index');
812814
}
813815

814816
// if (!$schema->hasTable('credentials')) {

core/Migrations/Version16000Date20190207141427.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
7777
'length' => 64,
7878
]);
7979

80-
$table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res');
80+
$table->setPrimaryKey(['collection_id', 'resource_type', 'resource_id'], 'crr_pk');
81+
// $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res');
8182
}
8283

8384
if (!$schema->hasTable('collres_accesscache')) {
@@ -106,7 +107,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
106107
'default' => 0,
107108
]);
108109

109-
$table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user');
110+
$table->setPrimaryKey(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'cra_pk');
111+
// $table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user');
110112
$table->addIndex(['user_id', 'resource_type', 'resource_id'], 'collres_user_res');
111113
$table->addIndex(['user_id', 'collection_id'], 'collres_user_coll');
112114
}

core/Migrations/Version17000Date20190514105811.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
6767
'length' => 20,
6868
'default' => 0,
6969
]);
70-
$table->addUniqueIndex(['fileid'], 'fce_fileid_idx');
70+
$table->setPrimaryKey(['fileid'], 'fce_pk');
71+
// $table->addUniqueIndex(['fileid'], 'fce_fileid_idx');
7172
$table->addIndex(['creation_time'], 'fce_ctime_idx');
7273
$table->addIndex(['upload_time'], 'fce_utime_idx');
7374
}

core/Migrations/Version18000Date20191204114856.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
5858
'length' => 4000,
5959
]);
6060

61-
6261
return $schema;
6362
}
6463
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
6+
*
7+
* @author Joas Schilling <coding@schilljs.com>
8+
*
9+
* @license GNU AGPL version 3 or any later version
10+
*
11+
* This program is free software: you can redistribute it and/or modify
12+
* it under the terms of the GNU Affero General Public License as
13+
* published by the Free Software Foundation, either version 3 of the
14+
* License, or (at your option) any later version.
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Affero General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Affero General Public License
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23+
*
24+
*/
25+
26+
namespace OC\Core\Migrations;
27+
28+
use Closure;
29+
use OCP\DB\ISchemaWrapper;
30+
use OCP\Migration\IOutput;
31+
use OCP\Migration\SimpleMigrationStep;
32+
33+
class Version20000Date20201109081920 extends SimpleMigrationStep {
34+
35+
/**
36+
* @param IOutput $output
37+
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38+
* @param array $options
39+
* @return null|ISchemaWrapper
40+
*/
41+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
42+
/** @var ISchemaWrapper $schema */
43+
$schema = $schemaClosure();
44+
$updated = false;
45+
46+
if ($schema->hasTable('systemtag_object_mapping')) {
47+
$table = $schema->getTable('systemtag_object_mapping');
48+
if (!$table->hasPrimaryKey()) {
49+
$table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk');
50+
if ($table->hasIndex('mapping')) {
51+
$table->dropIndex('mapping');
52+
}
53+
$updated = true;
54+
}
55+
}
56+
57+
if ($schema->hasTable('comments_read_markers')) {
58+
$table = $schema->getTable('comments_read_markers');
59+
if (!$table->hasPrimaryKey()) {
60+
$table->setPrimaryKey(['user_id', 'object_type', 'object_id'], 'crm_pk');
61+
if ($table->hasIndex('comments_marker_index')) {
62+
$table->dropIndex('comments_marker_index');
63+
}
64+
$updated = true;
65+
}
66+
}
67+
68+
if ($schema->hasTable('collres_resources')) {
69+
$table = $schema->getTable('collres_resources');
70+
if (!$table->hasPrimaryKey()) {
71+
$table->setPrimaryKey(['collection_id', 'resource_type', 'resource_id'], 'crr_pk');
72+
if ($table->hasIndex('collres_unique_res')) {
73+
$table->dropIndex('collres_unique_res');
74+
}
75+
$updated = true;
76+
}
77+
}
78+
79+
if ($schema->hasTable('collres_accesscache')) {
80+
$table = $schema->getTable('collres_accesscache');
81+
if (!$table->hasPrimaryKey()) {
82+
$table->setPrimaryKey(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'cra_pk');
83+
if ($table->hasIndex('collres_unique_user')) {
84+
$table->dropIndex('collres_unique_user');
85+
}
86+
$updated = true;
87+
}
88+
}
89+
90+
if ($schema->hasTable('filecache_extended')) {
91+
$table = $schema->getTable('filecache_extended');
92+
if (!$table->hasPrimaryKey()) {
93+
$table->setPrimaryKey(['fileid'], 'fce_pk');
94+
if ($table->hasIndex('fce_fileid_idx')) {
95+
$table->dropIndex('fce_fileid_idx');
96+
}
97+
$updated = true;
98+
}
99+
}
100+
101+
return $updated ? $schema : null;
102+
}
103+
}

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel
3030
// when updating major/minor version number.
3131

32-
$OC_Version = [21, 0, 0, 5];
32+
$OC_Version = [21, 0, 0, 6];
3333

3434
// The human readable string
3535
$OC_VersionString = '21.0.0 alpha';

0 commit comments

Comments
 (0)