Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Update module migrate command to avoid errors.

* Fixed issue nabeelio#1414
  • Loading branch information
YashGovekar committed Oct 24, 2022
1 parent 2f9e858 commit b4311b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
20 changes: 16 additions & 4 deletions app/Services/ImportExport/FlightImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,22 @@ public function import(array $row, $index): bool
}

// Create/check that they exist
$this->processAirport($row['dpt_airport']);
$this->processAirport($row['arr_airport']);
$process_dep = $this->processAirport($row['dpt_airport']);
if (is_null($process_dep)) {
$this->log('Could not import row '.$index.'. Departure Airport not found!');
return false;
}
$process_arr = $this->processAirport($row['arr_airport']);
if (is_null($process_arr)) {
$this->log('Could not import row '.$index.'. Arrival Airport not found!');
return false;
}
if ($row['alt_airport']) {
$this->processAirport($row['alt_airport']);
$process_alt = $this->processAirport($row['alt_airport']);
if (is_null($process_alt)) {
$this->log('Could not import row '.$index.'. Alternate Airport not found!');
return false;
}
}

// Check/calculate the distance
Expand Down Expand Up @@ -198,7 +210,7 @@ protected function setDays($day_str)
*
* @return Airport
*/
protected function processAirport($airport): Airport
protected function processAirport($airport): Airport|null
{
return $this->airportSvc->lookupAirportIfNotFound($airport);
}
Expand Down
6 changes: 3 additions & 3 deletions app/Services/ModuleService.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function addModule($module_name): bool
]);

try {
Artisan::call('module:migrate '.$module_name, ['--force' => true]);
Artisan::call('module:migrate '.$module_name);
} catch (Exception $e) {
Log::error('Error running migration for '.$module_name.'; error='.$e);
}
Expand Down Expand Up @@ -269,7 +269,7 @@ public function installModule(UploadedFile $file): FlashNotifier
}

Artisan::call('config:cache');
Artisan::call('module:migrate '.$module, ['--force' => true]);
Artisan::call('module:migrate '.$module);

return flash()->success('Module Installed');
}
Expand All @@ -290,7 +290,7 @@ public function updateModule($id, $status): bool
]);

if ($status === true) {
Artisan::call('module:migrate '.$module->name, ['--force' => true]);
Artisan::call('module:migrate '.$module->name);
}

return true;
Expand Down

0 comments on commit b4311b8

Please sign in to comment.