Skip to content

Commit

Permalink
Merge pull request #9540 from jonasraoni/bugfix/main/9487-fix-migrati…
Browse files Browse the repository at this point in the history
…on-exception

#9487 Skipped non-conforming setting tables from failing t…
  • Loading branch information
jonasraoni authored Jan 11, 2024
2 parents 5b4e837 + c64eaeb commit 6453a59
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions classes/migration/upgrade/PKPv3_3_0UpgradeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use APP\core\Services;
use APP\facades\Repo;
use Exception;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Database\Schema\Blueprint;
Expand Down Expand Up @@ -768,9 +769,13 @@ private function _settingsAsJSON()
$this->_toJSON($row, $tableName, ['plugin_name', 'context_id', 'setting_name'], 'setting_value');
});
} elseif (Schema::hasColumn($tableName, 'setting_type')) {
DB::table($tableName)->where('setting_type', 'object')->get()->each(function ($row) use ($tableName) {
$this->_toJSON($row, $tableName, ['setting_name', 'locale'], 'setting_value');
});
try {
$settings = DB::table($tableName, 's')->where('setting_type', 'object')->get(['setting_name', 'setting_value', 's.*']);
} catch (Exception $e) {
error_log("Failed to migrate the settings entity \"{$tableName}\"\n" . $e);
continue;
}
$settings->each(fn ($row) => $this->_toJSON($row, $tableName, ['setting_name', 'locale'], 'setting_value'));
}
}

Expand Down

0 comments on commit 6453a59

Please sign in to comment.