Skip to content

Commit

Permalink
fix: fixed migration command with the new database structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile committed Dec 15, 2022
1 parent ccf6e0c commit 4ab4b1f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions app/Console/Commands/MigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ public function handle(): int
$validator->setData($record);
if ($validator->passes()) {
$installation = Installation::firstOrNew([
'uuid' => $record['uuid'],
], [
'type' => $record['type'] == 'NULL' ? null : $record['type'],
'data->uuid' => $record['uuid'],
]);
$installationData = $installation->data;
$installationData['installation'] = 'nethserver';
$installationData['facts']['type'] = $record['type'] == 'NULL' ? null : $record['type'];
$installationData['facts']['version'] = $record['release_tag'];

$installation->created_at = $record['reg_date'];
$installation->updated_at = $record['reg_date'];

Expand All @@ -115,12 +118,7 @@ public function handle(): int
])
);

$installation->version()->associate(
Version::firstOrCreate([
'tag' => $record['release_tag'],
])
);

$installation->data = $installationData;
$installation->save();
} else {
$validationFailureCount++;
Expand Down

0 comments on commit 4ab4b1f

Please sign in to comment.