Fixes for migration file location

This commit is contained in:
David Bomba 2020-11-30 08:28:12 +11:00
parent 7d96a6d389
commit d7dd592d18
2 changed files with 8 additions and 6 deletions

View File

@ -320,7 +320,8 @@ class MigrationController extends BaseController
$migration_file = $request->file($company->company_index) $migration_file = $request->file($company->company_index)
->storeAs( ->storeAs(
'migrations', 'migrations',
$request->file($company->company_index)->getClientOriginalName() $request->file($company->company_index)->getClientOriginalName(),
'local'
); );
if (app()->environment() == 'testing') { if (app()->environment() == 'testing') {
@ -328,7 +329,9 @@ class MigrationController extends BaseController
} }
try { try {
StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(5)); // StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(5));
info($migration_file);
StartMigration::dispatch($migration_file, $user, $fresh_company);
} catch (\Exception $e) { } catch (\Exception $e) {
info($e->getMessage()); info($e->getMessage());
} }

View File

@ -85,8 +85,7 @@ class StartMigration implements ShouldQueue
$this->company->save(); $this->company->save();
$zip = new ZipArchive(); $zip = new ZipArchive();
$archive = $zip->open($this->filepath); $archive = $zip->open(storage_path("app/{$this->filepath}"));
$filename = pathinfo($this->filepath, PATHINFO_FILENAME); $filename = pathinfo($this->filepath, PATHINFO_FILENAME);
try { try {
@ -94,14 +93,14 @@ class StartMigration implements ShouldQueue
throw new ProcessingMigrationArchiveFailed('Processing migration archive failed. Migration file is possibly corrupted.'); throw new ProcessingMigrationArchiveFailed('Processing migration archive failed. Migration file is possibly corrupted.');
} }
$zip->extractTo(storage_path("migrations/{$filename}")); $zip->extractTo(storage_path("app/migrations/{$filename}"));
$zip->close(); $zip->close();
if (app()->environment() == 'testing') { if (app()->environment() == 'testing') {
return true; return true;
} }
$file = storage_path("migrations/$filename/migration.json"); $file = storage_path("app/migrations/$filename/migration.json");
if (! file_exists($file)) { if (! file_exists($file)) {
throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.'); throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.');