-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp/pkp-lib#10874 Remove submission stage ID from user_group_stage du…
…ring migration
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
classes/migration/upgrade/v3_5_0/I10874_UserGroupStagesRemoveSubmission.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/** | ||
* @file classes/migration/upgrade/v3_5_0/I10874_UserGroupStagesRemoveSubmission.php | ||
* | ||
* Copyright (c) 2025 Simon Fraser University | ||
* Copyright (c) 2025 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class I10874_UserGroupStagesRemoveSubmission | ||
* | ||
* @brief Remove WORKFLOW_STAGE_ID_SUBMISSION stage from user_group_stage table | ||
*/ | ||
|
||
namespace APP\migration\upgrade\v3_5_0; | ||
|
||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\DB; | ||
use PKP\migration\Migration; | ||
|
||
class I10874_UserGroupStagesRemoveSubmission extends Migration | ||
{ | ||
public const WORKFLOW_STAGE_SUBMISSION = 1; | ||
|
||
protected Collection $rowsWithSubmissionStage; | ||
|
||
public function up(): void | ||
{ | ||
$this->rowsWithSubmissionStage = DB::table('user_group_stage') | ||
->where('stage_id', self::WORKFLOW_STAGE_SUBMISSION) | ||
->get(); | ||
|
||
DB::table('user_group_stage')->where('stage_id', self::WORKFLOW_STAGE_SUBMISSION)->delete(); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
$toInsert = []; | ||
foreach ($this->rowsWithSubmissionStage as $row) { /* @var \stdClass $row */ | ||
$toInsert[] = [ | ||
'context_id' => $row->context_id, | ||
'user_group_id' => $row->user_group_id, | ||
'stage_id' => $row->stage_id, | ||
]; | ||
} | ||
|
||
DB::table('user_group_stage')->insert($toInsert); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters