From 1372827ccf45a04f1089c3bc6d8c9fcd03c75db0 Mon Sep 17 00:00:00 2001 From: Alec Smecher Date: Mon, 8 Jun 2020 16:22:32 -0700 Subject: [PATCH] pkp/pkp-lib#2493 Port XML-based upgrade to migration --- ...v3_2_1SubeditorCategoriesMigration.inc.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 classes/migration/upgrade/v3_2_1SubeditorCategoriesMigration.inc.php diff --git a/classes/migration/upgrade/v3_2_1SubeditorCategoriesMigration.inc.php b/classes/migration/upgrade/v3_2_1SubeditorCategoriesMigration.inc.php new file mode 100644 index 00000000000..9efa1207f25 --- /dev/null +++ b/classes/migration/upgrade/v3_2_1SubeditorCategoriesMigration.inc.php @@ -0,0 +1,56 @@ +rename('section_editors', 'subeditor_submission_group'); + Capsule::schema()->table('subeditor_submission_group', function (Blueprint $table) { + // Change section_id to assoc_type/assoc_id + $table->bigInteger('assoc_type'); + $table->renameColumn('section_id', 'assoc_id'); + + // Drop indexes + $table->dropIndex('section_editors_pkey'); + $table->dropIndex('section_editors_context_id'); + $table->dropIndex('section_editors_section_id'); + $table->dropIndex('section_editors_user_id'); + + // Create indexes + $table->index(['context_id'], 'section_editors_context_id'); + $table->index(['assoc_id', 'assoc_type'], 'subeditor_submission_group_assoc_id'); + $table->index(['user_id'], 'subeditor_submission_group_user_id'); + $table->unique(['context_id', 'assoc_id', 'assoc_type', 'user_id'], 'section_editors_pkey'); + }); + + // Populate the assoc_type data in the newly created column + Capsule::table('subeditor_submission_group')->update(['assoc_type' => ASSOC_TYPE_SECTION]); + } + + /** + * Reverse the downgrades + * @return void + */ + public function down() { + throw new Exception('Downgrade not supported.'); + } +}