Skip to content

Commit

Permalink
pkp/pkp-lib#8598 DB Migration changes
Browse files Browse the repository at this point in the history
  • Loading branch information
defstat committed Feb 8, 2023
1 parent e1d2553 commit 0b25074
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions classes/migration/upgrade/v3_4_0/MergeLocalesMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* @file classes/migration/upgrade/v3_4_0/MergeLocalesMigration.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class MergeLocalesMigration
*
* @brief Change Locales from locale_countryCode localization folder notation to locale localization folder notation
*/

namespace APP\migration\upgrade\v3_4_0;

use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use PKP\install\DowngradeNotSupportedException;

class MergeLocalesMigration extends \PKP\migration\upgrade\v3_4_0\MergeLocalesMigration
{
protected string $CONTEXT_TABLE = 'journals';
protected string $CONTEXT_SETTINGS_TABLE = 'journal_settings';
protected string $CONTEXT_COLUMN = 'journal_id';

/**
* Run the migrations.
*/
public function up(): void
{
parent::up();

// issue_galleys
$issueGalleys = DB::table('issue_galleys')
->get();

foreach ($issueGalleys as $issueGalley) {
$this->updateSingleValueLocale($issueGalley->locale, 'issue_galleys', 'locale', 'galley_id', $issueGalley->galley_id);
}

// publication_galleys
$publicationGalleys = DB::table('publication_galleys')
->get();

foreach ($publicationGalleys as $publicationGalley) {
$this->updateSingleValueLocale($publicationGalley->locale, 'publication_galleys', 'locale', 'galley_id', $publicationGalley->galley_id);
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
throw new DowngradeNotSupportedException();
}

protected function getSettingsTables(): Collection
{
return collect([
'issue_galley_settings',
'issue_settings',
'journal_settings',
'publication_galley_settings',
'section_settings',
'static_page_settings',
'subscription_type_settings'
])->merge(parent::getSettingsTables());
}
}

0 comments on commit 0b25074

Please sign in to comment.