Skip to content

Commit

Permalink
Ensures migration gets published just once (#50361)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro authored Mar 4, 2024
1 parent ae3245f commit ed93be8
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Illuminate/Foundation/Console/ApiInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,18 @@ protected function installSanctum()
'laravel/sanctum:^4.0',
]);

$php = (new PhpExecutableFinder())->find(false) ?: 'php';

$result = Process::run([
$php,
defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan',
'vendor:publish',
'--provider',
'Laravel\\Sanctum\\SanctumServiceProvider',
]);
$migrationPublished = collect(scandir($this->laravel->databasePath('migrations')))->contains(function ($migration) {
return preg_match('/\d{4}_\d{2}_\d{2}_\d{6}_create_personal_access_tokens_table.php/', $migration);
});

if (! $migrationPublished) {
Process::run([
(new PhpExecutableFinder())->find(false) ?: 'php',
defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan',
'vendor:publish',
'--provider',
'Laravel\\Sanctum\\SanctumServiceProvider',
]);
}
}
}

0 comments on commit ed93be8

Please sign in to comment.