Skip to content

Commit 8fc443d

Browse files
committed
fix: add unique index for users' mountpoints
Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com>
1 parent dc48b6b commit 8fc443d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

core/Listener/AddMissingIndicesListener.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,13 @@ public function handle(Event $event): void {
186186
'mounts_class_index',
187187
['mount_provider_class']
188188
);
189-
$event->addMissingIndex(
189+
190+
$event->replaceIndex(
190191
'mounts',
191-
'mounts_user_root_path_index',
192+
['mounts_user_root_path_index'],
193+
'mounts_user_root_path_unique_index',
192194
['user_id', 'root_id', 'mount_point'],
195+
true,
193196
['lengths' => [null, null, 128]]
194197
);
195198

core/Migrations/Version13000Date20170718121200.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
121121
$table->addIndex(['storage_id'], 'mounts_storage_index');
122122
$table->addIndex(['root_id'], 'mounts_root_index');
123123
$table->addIndex(['mount_id'], 'mounts_mount_id_index');
124-
$table->addIndex(['user_id', 'root_id', 'mount_point'], 'mounts_user_root_path_index', [], ['lengths' => [null, null, 128]]);
124+
$table->addUniqueIndex(['user_id', 'root_id', 'mount_point'], 'mounts_user_root_path_unique_index', ['lengths' => [null, null, 128]]);
125125
} else {
126126
$table = $schema->getTable('mounts');
127127
if (!$table->hasColumn('mount_id')) {

0 commit comments

Comments
 (0)