Skip to content

Commit

Permalink
pkp#10362 check if data exists before running migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitlinnewson committed Dec 19, 2024
1 parent 3a750ac commit dee1d47
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions classes/migration/upgrade/v3_5_0/I10362_EventLogEditorNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,26 @@ public function up(): void
->pluck('user_id', 'log_id');

$inserts = [];
foreach ($idsToUpdate as $eventLogId => $userId) {
$editorName = Repo::user()->get($userId)->getFullName();

if ($editorName) {
$inserts[] = [
'log_id' => $eventLogId,
'locale' => '',
'setting_name' => 'editorName',
'setting_value' => $editorName
];
if ($idsToUpdate) {
foreach ($idsToUpdate as $eventLogId => $userId) {
$editorName = Repo::user()->get($userId)->getFullName();

if ($editorName) {
$inserts[] = [
'log_id' => $eventLogId,
'locale' => '',
'setting_name' => 'editorName',
'setting_value' => $editorName
];
}
}
}

DB::table('event_log_settings')
->insert($inserts);
if ($inserts) {
DB::table('event_log_settings')
->insert($inserts);
}
}

/**
Expand Down

0 comments on commit dee1d47

Please sign in to comment.