Skip to content

Commit

Permalink
pkp#7167 Ensured index is removed in MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Dec 3, 2021
1 parent aabc4c1 commit dd9b08a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classes/migration/install/CommonMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function up(): void
$table->string('setting_name', 255);
$table->text('setting_value')->nullable();
$table->index(['user_id'], 'user_settings_user_id');
$table->primary(['user_id', 'locale', 'setting_name']);
$table->unique(['user_id', 'locale', 'setting_name'], 'user_settings_pkey');
$table->index(['setting_name', 'locale'], 'user_settings_locale_setting_name_index');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace PKP\migration\upgrade\v3_4_0;

use Exception;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -96,10 +95,10 @@ public function up(): void
Schema::table(
'user_settings',
function (Blueprint $table): void {
// Drop deprecated fields (this will implicitly drop the unique key "user_settings_pkey")
$table->dropIndex('user_settings_pkey');
$table->dropColumn('assoc_id', 'assoc_type');
// Restore the primary/unique index, using the previous field order
$table->primary(['user_id', 'locale', 'setting_name']);
$table->unique(['user_id', 'locale', 'setting_name'], 'user_settings_pkey');
}
);
}
Expand Down

0 comments on commit dd9b08a

Please sign in to comment.