Skip to content

Commit ed93be8

Browse files
authored
Ensures migration gets published just once (#50361)
1 parent ae3245f commit ed93be8

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/Illuminate/Foundation/Console/ApiInstallCommand.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,18 @@ protected function installSanctum()
9393
'laravel/sanctum:^4.0',
9494
]);
9595

96-
$php = (new PhpExecutableFinder())->find(false) ?: 'php';
97-
98-
$result = Process::run([
99-
$php,
100-
defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan',
101-
'vendor:publish',
102-
'--provider',
103-
'Laravel\\Sanctum\\SanctumServiceProvider',
104-
]);
96+
$migrationPublished = collect(scandir($this->laravel->databasePath('migrations')))->contains(function ($migration) {
97+
return preg_match('/\d{4}_\d{2}_\d{2}_\d{6}_create_personal_access_tokens_table.php/', $migration);
98+
});
99+
100+
if (! $migrationPublished) {
101+
Process::run([
102+
(new PhpExecutableFinder())->find(false) ?: 'php',
103+
defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan',
104+
'vendor:publish',
105+
'--provider',
106+
'Laravel\\Sanctum\\SanctumServiceProvider',
107+
]);
108+
}
105109
}
106110
}

0 commit comments

Comments
 (0)