Skip to content

Commit

Permalink
#2493 Add DowngradeNotSupportedException for more graceful backout; r…
Browse files Browse the repository at this point in the history
…econciled 3.0.x/3.2.x upgrade expectations
  • Loading branch information
asmecher committed Aug 27, 2020
1 parent e1de408 commit 2de6f74
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 44 deletions.
6 changes: 5 additions & 1 deletion classes/install/Installer.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,11 @@ function executeAction($action) {

// Back out already-executed migrations.
while ($previousMigration = array_pop($this->migrations)) {
$previousMigration->down();
try {
$previousMigration->down();
} catch (PKP\install\DowngradeNotSupportedException $e) {
break;
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ public function up() {
* @return void
*/
public function down() {
throw new Exception('Downgrade not supported.');
throw new PKP\install\DowngradeNotSupportedException();
}
}
13 changes: 8 additions & 5 deletions classes/migration/upgrade/PKPv3_3_0UpgradeMigration.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public function up() {
$table->date('date_expire')->change();
});

Capsule::schema()->table('email_templates_default', function (Blueprint $table) {
// pkp/pkp-lib#4796 stage ID as a filter parameter to email templates
$table->bigInteger('stage_id')->nullable();
});
// Transitional: The stage_id column may have already been added by the ADODB schema toolset
if (!Capsule::schema()->hasColumn('email_templates_default', 'stage_id')) {
Capsule::schema()->table('email_templates_default', function (Blueprint $table) {
// pkp/pkp-lib#4796 stage ID as a filter parameter to email templates
$table->bigInteger('stage_id')->nullable();
});
}

// pkp/pkp-lib#6093 Don't allow nulls (previously an upgrade workaround)
Capsule::schema()->table('user_settings', function (Blueprint $table) {
Expand Down Expand Up @@ -101,7 +104,7 @@ public function up() {
* @return void
*/
public function down() {
throw new Exception('Downgrade not supported.');
throw new PKP\install\DowngradeNotSupportedException();
}

/**
Expand Down
1 change: 1 addition & 0 deletions xml/schema/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@
<NOTNULL/>
<DEFAULT VALUE="1"/>
</field>
<field name="stage_id" type="I8"/>
<field name="from_role_id" type="I8"/>
<field name="to_role_id" type="I8"/>
<descr>Default email templates.</descr>
Expand Down
37 changes: 0 additions & 37 deletions xml/schema/submissions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,43 +255,6 @@
</index>
</table>

<!--
*
* TABLE subeditor_submission_group
*
-->
<table name="subeditor_submission_group">
<field name="context_id" type="I8">
<NOTNULL />
</field>
<field name="assoc_id" type="I8">
<NOTNULL />
</field>
<field name="user_id" type="I8">
<NOTNULL />
</field>
<field name="assoc_type" type="I8">
<NOTNULL />
</field>
<descr>Assignments of sub editors to submission groups.</descr>
<index name="subeditor_submission_group_context_id">
<col>context_id</col>
</index>
<index name="subeditor_submission_group_assoc_id">
<col>assoc_id</col>
</index>
<index name="subeditor_submission_group_user_id">
<col>user_id</col>
</index>
<index name="section_editors_pkey">
<col>context_id</col>
<col>assoc_id</col>
<col>user_id</col>
<col>assoc_type</col>
<UNIQUE />
</index>
</table>

<!--
*
* TABLE queries
Expand Down

0 comments on commit 2de6f74

Please sign in to comment.