From f0ed82f85df1af75b7ae5afcf9aa7a9011630ab3 Mon Sep 17 00:00:00 2001 From: Alec Smecher Date: Mon, 18 Dec 2023 18:08:42 -0800 Subject: [PATCH] Drop indexes only if they exist (https://forum.pkp.sfu.ca/t/ojs-upgrade-error-from-3-3-0-15-to-3-4-0-0/83644) --- .../upgrade/v3_4_0/I7249_UpdateUsersUniqueIndex_v3_1.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/migration/upgrade/v3_4_0/I7249_UpdateUsersUniqueIndex_v3_1.php b/classes/migration/upgrade/v3_4_0/I7249_UpdateUsersUniqueIndex_v3_1.php index 4a2d3fa5c9e..025d8a49c6f 100644 --- a/classes/migration/upgrade/v3_4_0/I7249_UpdateUsersUniqueIndex_v3_1.php +++ b/classes/migration/upgrade/v3_4_0/I7249_UpdateUsersUniqueIndex_v3_1.php @@ -23,8 +23,8 @@ public function up(): void { switch (DB::getDriverName()) { case 'pgsql': - DB::unprepared('DROP INDEX users_username;'); - DB::unprepared('DROP INDEX users_email;'); + DB::unprepared('DROP INDEX IF EXISTS users_username;'); + DB::unprepared('DROP INDEX IF EXISTS users_email;'); DB::unprepared('CREATE UNIQUE INDEX users_username on users (LOWER(username));'); DB::unprepared('CREATE UNIQUE INDEX users_email on users (LOWER(email));'); @@ -36,8 +36,8 @@ public function down(): void { switch (DB::getDriverName()) { case 'pgsql': - DB::unprepared('DROP INDEX users_username;'); - DB::unprepared('DROP INDEX users_email;'); + DB::unprepared('DROP INDEX IF EXISTS users_username;'); + DB::unprepared('DROP INDEX IF EXISTS users_email;'); DB::unprepared('CREATE UNIQUE INDEX users_username on users (username);'); DB::unprepared('CREATE UNIQUE INDEX users_email on users (email);');