Skip to content

Commit

Permalink
pkp/pkp-lib#8598 DB Migration added
Browse files Browse the repository at this point in the history
  • Loading branch information
defstat committed Feb 14, 2023
1 parent 68905f3 commit ab97159
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
59 changes: 59 additions & 0 deletions classes/migration/upgrade/v3_4_0/MergeLocalesMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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 = 'servers';
protected string $CONTEXT_SETTINGS_TABLE = 'server_settings';
protected string $CONTEXT_COLUMN = 'server_id';

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

// 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([
'server_settings' => 'server_id',
'publication_galley_settings' => 'galley_id',
'section_settings' => 'section_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 @@ -84,6 +84,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"/>
<note file="docs/release-notes/README-3.4.0" />
</upgrade>

Expand Down

0 comments on commit ab97159

Please sign in to comment.