Skip to content

Commit

Permalink
#7678 Relax unique index for merged users case
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Feb 18, 2022
1 parent f18f00f commit 480c151
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion classes/migration/install/ReviewsMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public function up(): void

$table->smallInteger('unconsidered')->nullable();

$table->unique(['review_round_id', 'reviewer_id'], 'review_assignment_reviewer_round_unique');
// Normally reviewer can't be assigned twice on the same review round.
// HOWEVER, if two reviewer user accounts are subsequently merged, both will keep
// separate review assignments but the reviewer_id will become the same!
// (https://github.com/pkp/pkp-lib/issues/7678)
$table->index(['review_round_id', 'reviewer_id'], 'review_assignment_reviewer_round');
$table->index(['submission_id'], 'review_assignments_submission_id');
$table->index(['reviewer_id'], 'review_assignments_reviewer_id');
$table->index(['review_form_id'], 'review_assignments_form_id');
Expand Down
10 changes: 7 additions & 3 deletions classes/migration/upgrade/v3_4_0/UpgradeMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ public function up(): void
$table->foreign('reviewer_id')->references('user_id')->on('users');
$table->foreign('review_round_id')->references('review_round_id')->on('review_rounds');
$table->foreign('review_form_id')->references('review_form_id')->on('review_forms');
// No reviewer can be assigned twice on the same review round.
$table->unique(['review_round_id', 'reviewer_id'], 'review_assignment_reviewer_round_unique');

// Normally reviewer can't be assigned twice on the same review round.
// HOWEVER, if two reviewer user accounts are subsequently merged, both will keep
// separate review assignments but the reviewer_id will become the same!
// (https://github.com/pkp/pkp-lib/issues/7678)
$table->index(['review_round_id', 'reviewer_id'], 'review_assignment_reviewer_round');
});

// pkp/pkp-lib#6685: Drop old tombstones table in OJS and OPS
Expand Down Expand Up @@ -90,7 +94,7 @@ public function down(): void
$table->dropForeign(['review_form_id']);
});
Schema::table('review_assignments', function (Blueprint $table) {
$table->dropUnique('review_assignment_reviewer_round_unique');
$table->dropIndex('review_assignment_reviewer_round');
});
Schema::table('users', function (Blueprint $table) {
$table->dateTime('date_last_login')->nullable(false)->default(null)->change();
Expand Down

0 comments on commit 480c151

Please sign in to comment.