Skip to content

Commit

Permalink
Adjusts install command
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Dec 22, 2023
1 parent c1b139f commit d04e4e0
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public function handle()
$this->configureUuids();
}

$this->call('migrate');

$this->call('passport:client', ['--personal' => true, '--name' => config('app.name').' Personal Access Client']);
$this->call('passport:client', ['--password' => true, '--name' => config('app.name').' Password Grant Client', '--provider' => $provider]);
}
Expand All @@ -58,17 +60,10 @@ protected function configureUuids()
Passport::setClientUuids(true);

$this->replaceInFile(config_path('passport.php'), '\'client_uuids\' => false', '\'client_uuids\' => true');
// @todo adjust with time updates...
$this->replaceInFile(database_path('migrations/2016_06_01_000001_create_oauth_auth_codes_table.php'), '$table->unsignedBigInteger(\'client_id\');', '$table->uuid(\'client_id\');');
$this->replaceInFile(database_path('migrations/2016_06_01_000002_create_oauth_access_tokens_table.php'), '$table->unsignedBigInteger(\'client_id\');', '$table->uuid(\'client_id\');');
$this->replaceInFile(database_path('migrations/2016_06_01_000004_create_oauth_clients_table.php'), '$table->bigIncrements(\'id\');', '$table->uuid(\'id\')->primary();');
$this->replaceInFile(database_path('migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php'), '$table->unsignedBigInteger(\'client_id\');', '$table->uuid(\'client_id\');');

if ($this->confirm('In order to finish configuring client UUIDs, we need to rebuild the Passport database tables. Would you like to rollback and re-run your last migration?')) {
$this->call('migrate:rollback');
$this->call('migrate');
$this->line('');
}
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_auth_codes_table.php'), '$table->unsignedBigInteger(\'client_id\');', '$table->uuid(\'client_id\');');
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_access_tokens_table.php'), '$table->unsignedBigInteger(\'client_id\');', '$table->uuid(\'client_id\');');
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_clients_table.php'), '$table->bigIncrements(\'id\');', '$table->uuid(\'id\')->primary();');
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_personal_access_clients_table.php'), '$table->unsignedBigInteger(\'client_id\');', '$table->uuid(\'client_id\');');
}

/**
Expand All @@ -81,9 +76,11 @@ protected function configureUuids()
*/
protected function replaceInFile($path, $search, $replace)
{
file_put_contents(
$path,
str_replace($search, $replace, file_get_contents($path))
);
foreach (glob($path) as $file) {
file_put_contents(
$file,
str_replace($search, $replace, file_get_contents($file))
);
}
}
}

0 comments on commit d04e4e0

Please sign in to comment.