From ad6ccdbd217d4ba44a9da3ffc9298bc68dc02803 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:12:45 +0100 Subject: [PATCH 1/2] fix: add index on migration only if needed Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- core/Migrations/Version28000Date20230803221055.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Migrations/Version28000Date20230803221055.php b/core/Migrations/Version28000Date20230803221055.php index 8878a6f6cce9b..3aaf4f19431a7 100644 --- a/core/Migrations/Version28000Date20230803221055.php +++ b/core/Migrations/Version28000Date20230803221055.php @@ -52,7 +52,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $column = $table->getColumn('user_id'); $column->setNotnull(false); - $table->addIndex(['user_id', 'app_id', 'identifier'], 'tp_tasks_uid_appid_ident'); + if (!$table->hasIndex('tp_tasks_uid_appid_ident')) { + $table->addIndex(['user_id', 'app_id', 'identifier'], 'tp_tasks_uid_appid_ident'); + } $changed = true; } From 659d7e2313ddf50104e1257968c5244306cad363 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Wed, 1 Nov 2023 17:17:44 +0100 Subject: [PATCH 2/2] Return only if changed Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- core/Migrations/Version28000Date20230803221055.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/Migrations/Version28000Date20230803221055.php b/core/Migrations/Version28000Date20230803221055.php index 3aaf4f19431a7..799eb15e06e91 100644 --- a/core/Migrations/Version28000Date20230803221055.php +++ b/core/Migrations/Version28000Date20230803221055.php @@ -54,9 +54,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt if (!$table->hasIndex('tp_tasks_uid_appid_ident')) { $table->addIndex(['user_id', 'app_id', 'identifier'], 'tp_tasks_uid_appid_ident'); + $changed = true; } - - $changed = true; } if ($changed) {