File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,7 @@ class ExtensionServiceProvider extends ServiceProvider
253253 Updates \RemoveParentField::class,
254254 Updates \UpdateGlobalVariables::class,
255255 Updates \PublishMigrationForTwoFactorColumns::class,
256+ Updates \PublishMigrationForWebauthnTable::class,
256257 Updates \AddAddonSettingsToGitConfig::class,
257258 ];
258259
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Statamic \UpdateScripts ;
4+
5+ use Illuminate \Support \Facades \File ;
6+ use Illuminate \Support \Str ;
7+
8+ class PublishMigrationForWebauthnTable extends UpdateScript
9+ {
10+ public function shouldUpdate ($ newVersion , $ oldVersion )
11+ {
12+ return $ this ->isUpdatingTo ('6.0.0 ' )
13+ && config ('statamic.users.repository ' , 'file ' ) === 'eloquent ' ;
14+ }
15+
16+ public function update ()
17+ {
18+ if (! $ this ->migrationExists ('statamic_webauthn_table ' )) {
19+ $ stub = __DIR__ .'/../Console/Commands/stubs/auth/statamic_webauthn_table.php.stub ' ;
20+ $ filename = date ('Y_m_d_His ' ).'_statamic_webauthn_table.php ' ;
21+
22+ File::put (database_path ("migrations/ $ filename " ), File::get ($ stub ));
23+
24+ $ this ->console ->line (sprintf (
25+ 'Migration <info>database/migrations/%s</info> created successfully. ' ,
26+ $ filename
27+ ));
28+
29+ $ this ->console ->line ('Run <comment>php artisan migrate</comment> to apply the migration. ' );
30+ }
31+ }
32+
33+ protected function migrationExists (string $ name ): bool
34+ {
35+ return collect (File::allFiles (database_path ('migrations ' )))
36+ ->map ->getFilename ()
37+ ->filter (fn (string $ filename ) => Str::contains ($ filename , $ name ))
38+ ->isNotEmpty ();
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments