Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.x] Refactor migrations #1759

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
public function up(): void
{
Schema::create('oauth_auth_codes', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('client_id');
$table->char('id', 80)->primary();
$table->foreignId('user_id');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no index here anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the column itself is redundant #1752

$table->foreignId('client_id');
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
Expand All @@ -28,4 +28,14 @@ public function down(): void
{
Schema::dropIfExists('oauth_auth_codes');
}

/**
* Get the migration connection name.
*
* @return string|null
*/
public function getConnection()
{
return $this->connection ?? config('passport.connection');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
public function up(): void
{
Schema::create('oauth_access_tokens', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->unsignedBigInteger('user_id')->nullable()->index();
$table->unsignedBigInteger('client_id');
$table->char('id', 80)->primary();
$table->foreignId('user_id')->nullable()->index();
$table->foreignId('client_id');
$table->string('name')->nullable();
$table->text('scopes')->nullable();
$table->boolean('revoked');
Expand All @@ -30,4 +30,14 @@ public function down(): void
{
Schema::dropIfExists('oauth_access_tokens');
}

/**
* Get the migration connection name.
*
* @return string|null
*/
public function getConnection()
{
return $this->connection ?? config('passport.connection');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
public function up(): void
{
Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->string('access_token_id', 100)->index();
$table->char('id', 80)->primary();
$table->char('access_token_id', 80)->index();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
Expand All @@ -26,4 +26,14 @@ public function down(): void
{
Schema::dropIfExists('oauth_refresh_tokens');
}

/**
* Get the migration connection name.
*
* @return string|null
*/
public function getConnection()
{
return $this->connection ?? config('passport.connection');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
public function up(): void
{
Schema::create('oauth_clients', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id')->nullable()->index();
$table->id();
$table->foreignId('user_id')->nullable()->index();
$table->string('name');
$table->string('secret', 100)->nullable();
$table->string('provider')->nullable();
Expand All @@ -32,4 +32,14 @@ public function down(): void
{
Schema::dropIfExists('oauth_clients');
}

/**
* Get the migration connection name.
*
* @return string|null
*/
public function getConnection()
{
return $this->connection ?? config('passport.connection');
}
};
6 changes: 3 additions & 3 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ protected function configureUuids()
Passport::setClientUuids(true);

$this->replaceInFile(config_path('passport.php'), '\'client_uuids\' => false', '\'client_uuids\' => true');
$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_auth_codes_table.php'), '$table->foreignId(\'client_id\');', '$table->foreignUuid(\'client_id\');');
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_access_tokens_table.php'), '$table->foreignId(\'client_id\');', '$table->foreignUuid(\'client_id\');');
$this->replaceInFile(database_path('migrations/****_**_**_******_create_oauth_clients_table.php'), '$table->id();', '$table->uuid(\'id\')->primary();');
}

/**
Expand Down