Open Monograph Press  3.3.0
PKPv3_2_1SubeditorCategoriesMigration.inc.php
1 <?php
2 
14 use Illuminate\Database\Migrations\Migration;
15 use Illuminate\Database\Schema\Builder;
16 use Illuminate\Database\Schema\Blueprint;
17 use Illuminate\Database\Capsule\Manager as Capsule;
18 
19 class PKPv3_2_1SubeditorCategoriesMigration extends Migration {
24  public function up() {
25  // Schema changes
26  Capsule::schema()->rename('section_editors', 'subeditor_submission_group');
27  Capsule::schema()->table('subeditor_submission_group', function (Blueprint $table) {
28  // Change section_id to assoc_type/assoc_id
29  $table->bigInteger('assoc_type');
30  $table->renameColumn('section_id', 'assoc_id');
31 
32  // Drop indexes
33  $table->dropIndex('section_editors_pkey');
34  $table->dropIndex('section_editors_context_id');
35  $table->dropIndex('section_editors_section_id');
36  $table->dropIndex('section_editors_user_id');
37 
38  // Create indexes
39  $table->index(['context_id'], 'section_editors_context_id');
40  $table->index(['assoc_id', 'assoc_type'], 'subeditor_submission_group_assoc_id');
41  $table->index(['user_id'], 'subeditor_submission_group_user_id');
42  $table->unique(['context_id', 'assoc_id', 'assoc_type', 'user_id'], 'section_editors_pkey');
43  });
44 
45  // Populate the assoc_type data in the newly created column
46  Capsule::table('subeditor_submission_group')->update(['assoc_type' => ASSOC_TYPE_SECTION]);
47  }
48 
53  public function down() {
55  }
56 }
PKP\install\DowngradeNotSupportedException
Definition: DowngradeNotSupportedException.inc.php:15
PKPv3_2_1SubeditorCategoriesMigration
pkp/pkp-lib#5694 Allow subeditors to be assigned to Categories
Definition: PKPv3_2_1SubeditorCategoriesMigration.inc.php:19
PKPv3_2_1SubeditorCategoriesMigration\down
down()
Definition: PKPv3_2_1SubeditorCategoriesMigration.inc.php:53
PKPv3_2_1SubeditorCategoriesMigration\up
up()
Definition: PKPv3_2_1SubeditorCategoriesMigration.inc.php:24