Skip to content

Commit

Permalink
#6057 Restore dropped sequence during migration
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr committed Nov 4, 2020
1 parent 93f6725 commit d6ccdd6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ private function _migrateSubmissionFiles() {
});
Capsule::schema()->table('review_files', function (Blueprint $table) {
$table->bigInteger('submission_file_id')->nullable(false)->unsigned()->change();
$table->dropIndex('review_files_pkey');
$table->unique(['review_id', 'submission_file_id'], 'review_files_pkey');
$table->foreign('submission_file_id')->references('submission_file_id')->on('submission_files');
});
Expand All @@ -417,10 +418,13 @@ private function _migrateSubmissionFiles() {
$table->foreign('file_id')->references('file_id')->on('files');
});

// Postgres leaves the old file_id autoincrement counter around, and
// needs to have the primary key re-applied
// Postgres leaves the old file_id autoincrement sequence around, so
// we delete it and apply a new sequence.
if (Config::getVar('database', 'driver') === 'postgres9') {
Capsule::statement('DROP SEQUENCE submission_files_file_id_seq CASCADE');
Capsule::schema()->table('submission_files', function (Blueprint $table) {
$table->bigIncrements('submission_file_id')->change();
});
}
}

Expand Down

0 comments on commit d6ccdd6

Please sign in to comment.