Skip to content

Commit

Permalink
fix: fix reset demo download issues (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Jun 9, 2021
1 parent 4213398 commit 30064d4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/Console/Commands/Demo/ResetDemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Console\ConfirmableTrait;

Expand Down Expand Up @@ -41,11 +42,19 @@ public function handle(): void
try {
Artisan::call('down');

$this->line('Downloading file...');
$file = Http::get('https://github.com/officelifehq/demosql/raw/main/officelife.sql');
if (Cache::has('databasereset')) {
$sql = Cache::get('databasereset');
} else {
$this->line('Downloading file...');
$file = Http::get('https://github.com/officelifehq/demosql/raw/main/officelife.sql');
$file->throw();

$sql = $file->body();
Cache::put('databasereset', $sql, 7200);
}

$this->line('Running transaction...');
DB::unprepared($file->body());
DB::unprepared($sql);

$this->line('Running migration...');
Artisan::call('migrate', ['--force' => true, '--verbose' => true]);
Expand Down

0 comments on commit 30064d4

Please sign in to comment.