diff --git a/src/Actions/UpdateIndex.php b/src/Actions/UpdateIndex.php index 3406380..5933091 100644 --- a/src/Actions/UpdateIndex.php +++ b/src/Actions/UpdateIndex.php @@ -7,15 +7,14 @@ use BenBjurstrom\Prezet\Models\Document; use BenBjurstrom\Prezet\Models\Heading; use BenBjurstrom\Prezet\Models\Tag; -use Illuminate\Database\QueryException; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Route; +use Illuminate\Support\Facades\Schema; class UpdateIndex { public static function handle(): void { - self::runMigrations(); $docs = GetAllFrontmatter::handle(); $docs->each(function (FrontmatterData $doc) { @@ -76,19 +75,15 @@ protected static function setTags(Document $d, array $tags): void protected static function runMigrations(): void { - try { - Artisan::call('migrate:rollback', [ - '--path' => base_path('vendor/benbjurstrom/prezet/database/migrations'), - '--database' => 'prezet', - '--realpath' => true, - '--no-interaction' => true, - ]); - } catch (QueryException $e) { - // either file does not exist or - // migrations table does not exist + if (! Schema::connection('prezet')->hasTable('migrations')) { + Schema::connection('prezet')->create('migrations', function ($table) { + $table->increments('id'); + $table->string('migration'); + $table->integer('batch'); + }); } - Artisan::call('migrate', [ + Artisan::call('migrate:fresh', [ '--path' => base_path('vendor/benbjurstrom/prezet/database/migrations'), '--database' => 'prezet', '--realpath' => true,