Skip to content

Commit

Permalink
Merge branch 'pkp/pkp-lib#8598-db-migration' into pkp/pkp-lib#8598-me…
Browse files Browse the repository at this point in the history
…rge-for-tests-2

# Conflicts:
#	cypress/tests/data/60-content/AmwandengaSubmission.cy.js
#	cypress/tests/integration/Z_ArticleViewDCMetadata.cy.js
#	plugins/importexport/pubmed/filter/ArticlePubMedXmlFilter.php
  • Loading branch information
defstat authored and asmecher committed Feb 17, 2023
1 parent fd84e97 commit 8cd8a08
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
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' => 'galley_id',
'issue_settings' => 'issue_id',
'journal_settings' => 'journal_id',
'publication_galley_settings' => 'galley_id',
'section_settings' => 'section_id',
'static_page_settings' => 'static_page_id',
'subscription_type_settings' => 'type_id',
])->merge(parent::getSettingsTables());
}
}
2 changes: 1 addition & 1 deletion config.TEMPLATE.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
[i18n]

; Default locale
locale = en_US
locale = en

; Database connection character set
connection_charset = utf8
Expand Down
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
<migration class="APP\migration\upgrade\v3_4_0\I7513_DoiSettings"/>
<migration class="PKP\migration\upgrade\v3_4_0\I7486_RenameUnconsideredColumnToConsidered"/>
<migration class="PKP\migration\upgrade\v3_4_0\I7486_RemoveItemViewsTable"/>
<migration class="APP\migration\upgrade\v3_4_0\MergeLocalesMigration"/>
<data file="dbscripts/xml/upgrade/3.4.0_preupdate_email_templates.xml" />
<note file="docs/release-notes/README-3.4.0" />
</upgrade>
Expand Down

0 comments on commit 8cd8a08

Please sign in to comment.