diff --git a/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php b/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php index 7b93b406..9a50ded4 100644 --- a/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php +++ b/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php @@ -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')->index(); + $table->foreignId('client_id'); $table->text('scopes')->nullable(); $table->boolean('revoked'); $table->dateTime('expires_at')->nullable(); @@ -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'); + } }; diff --git a/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php b/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php index 598798ee..97f78510 100644 --- a/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php +++ b/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php @@ -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'); @@ -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'); + } }; diff --git a/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php b/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php index b007904c..c94c91ab 100644 --- a/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php +++ b/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php @@ -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(); }); @@ -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'); + } }; diff --git a/database/migrations/2016_06_01_000004_create_oauth_clients_table.php b/database/migrations/2016_06_01_000004_create_oauth_clients_table.php index 776ccfab..1ed6feed 100644 --- a/database/migrations/2016_06_01_000004_create_oauth_clients_table.php +++ b/database/migrations/2016_06_01_000004_create_oauth_clients_table.php @@ -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(); @@ -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'); + } }; diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index a9ffb38a..87bd95f4 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -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();'); } /**