From fb950814a5bf86473a53f98c14312b761e1b0a39 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Mon, 22 Feb 2021 15:13:46 +0100 Subject: [PATCH] Revert model DB connection customization (#1412) --- config/passport.php | 17 ---------- ...1_000001_create_oauth_auth_codes_table.php | 31 ++----------------- ...00002_create_oauth_access_tokens_table.php | 31 ++----------------- ...0003_create_oauth_refresh_tokens_table.php | 31 ++----------------- ...6_01_000004_create_oauth_clients_table.php | 31 ++----------------- ...te_oauth_personal_access_clients_table.php | 31 ++----------------- src/AuthCode.php | 10 ------ src/Client.php | 10 ------ src/PersonalAccessClient.php | 10 ------ src/RefreshToken.php | 10 ------ src/Token.php | 10 ------ tests/Feature/PassportTestCase.php | 2 -- 12 files changed, 10 insertions(+), 214 deletions(-) diff --git a/config/passport.php b/config/passport.php index 162f1f84a..79c59acb1 100644 --- a/config/passport.php +++ b/config/passport.php @@ -46,21 +46,4 @@ 'secret' => env('PASSPORT_PERSONAL_ACCESS_CLIENT_SECRET'), ], - /* - |-------------------------------------------------------------------------- - | Passport Storage Driver - |-------------------------------------------------------------------------- - | - | This configuration value allows you to customize the storage options - | for Passport, such as the database connection that should be used - | by Passport's internal database models which store tokens, etc. - | - */ - - 'storage' => [ - 'database' => [ - 'connection' => env('DB_CONNECTION', 'mysql'), - ], - ], - ]; 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 0eabf059c..6c47d2473 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 @@ -6,23 +6,6 @@ class CreateOauthAuthCodesTable extends Migration { - /** - * The database schema. - * - * @var \Illuminate\Database\Schema\Builder - */ - protected $schema; - - /** - * Create a new migration instance. - * - * @return void - */ - public function __construct() - { - $this->schema = Schema::connection($this->getConnection()); - } - /** * Run the migrations. * @@ -30,7 +13,7 @@ public function __construct() */ public function up() { - $this->schema->create('oauth_auth_codes', function (Blueprint $table) { + Schema::create('oauth_auth_codes', function (Blueprint $table) { $table->string('id', 100)->primary(); $table->unsignedBigInteger('user_id')->index(); $table->unsignedBigInteger('client_id'); @@ -47,16 +30,6 @@ public function up() */ public function down() { - $this->schema->dropIfExists('oauth_auth_codes'); - } - - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); + Schema::dropIfExists('oauth_auth_codes'); } } 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 67c682d5f..00f00633a 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 @@ -6,23 +6,6 @@ class CreateOauthAccessTokensTable extends Migration { - /** - * The database schema. - * - * @var \Illuminate\Database\Schema\Builder - */ - protected $schema; - - /** - * Create a new migration instance. - * - * @return void - */ - public function __construct() - { - $this->schema = Schema::connection($this->getConnection()); - } - /** * Run the migrations. * @@ -30,7 +13,7 @@ public function __construct() */ public function up() { - $this->schema->create('oauth_access_tokens', function (Blueprint $table) { + Schema::create('oauth_access_tokens', function (Blueprint $table) { $table->string('id', 100)->primary(); $table->unsignedBigInteger('user_id')->nullable()->index(); $table->unsignedBigInteger('client_id'); @@ -49,16 +32,6 @@ public function up() */ public function down() { - $this->schema->dropIfExists('oauth_access_tokens'); - } - - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); + Schema::dropIfExists('oauth_access_tokens'); } } 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 b4ac09544..60c523489 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 @@ -6,23 +6,6 @@ class CreateOauthRefreshTokensTable extends Migration { - /** - * The database schema. - * - * @var \Illuminate\Database\Schema\Builder - */ - protected $schema; - - /** - * Create a new migration instance. - * - * @return void - */ - public function __construct() - { - $this->schema = Schema::connection($this->getConnection()); - } - /** * Run the migrations. * @@ -30,7 +13,7 @@ public function __construct() */ public function up() { - $this->schema->create('oauth_refresh_tokens', function (Blueprint $table) { + Schema::create('oauth_refresh_tokens', function (Blueprint $table) { $table->string('id', 100)->primary(); $table->string('access_token_id', 100)->index(); $table->boolean('revoked'); @@ -45,16 +28,6 @@ public function up() */ public function down() { - $this->schema->dropIfExists('oauth_refresh_tokens'); - } - - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); + Schema::dropIfExists('oauth_refresh_tokens'); } } 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 6ce3d9974..f0884ee7b 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 @@ -6,33 +6,6 @@ class CreateOauthClientsTable extends Migration { - /** - * The database schema. - * - * @var \Illuminate\Database\Schema\Builder - */ - protected $schema; - - /** - * Create a new migration instance. - * - * @return void - */ - public function __construct() - { - $this->schema = Schema::connection($this->getConnection()); - } - - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); - } - /** * Run the migrations. * @@ -40,7 +13,7 @@ public function getConnection() */ public function up() { - $this->schema->create('oauth_clients', function (Blueprint $table) { + Schema::create('oauth_clients', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedBigInteger('user_id')->nullable()->index(); $table->string('name'); @@ -61,6 +34,6 @@ public function up() */ public function down() { - $this->schema->dropIfExists('oauth_clients'); + Schema::dropIfExists('oauth_clients'); } } diff --git a/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php b/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php index c408248f5..4b56435ce 100644 --- a/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php +++ b/database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php @@ -6,23 +6,6 @@ class CreateOauthPersonalAccessClientsTable extends Migration { - /** - * The database schema. - * - * @var \Illuminate\Database\Schema\Builder - */ - protected $schema; - - /** - * Create a new migration instance. - * - * @return void - */ - public function __construct() - { - $this->schema = Schema::connection($this->getConnection()); - } - /** * Run the migrations. * @@ -30,7 +13,7 @@ public function __construct() */ public function up() { - $this->schema->create('oauth_personal_access_clients', function (Blueprint $table) { + Schema::create('oauth_personal_access_clients', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedBigInteger('client_id'); $table->timestamps(); @@ -44,16 +27,6 @@ public function up() */ public function down() { - $this->schema->dropIfExists('oauth_personal_access_clients'); - } - - /** - * Get the migration connection name. - * - * @return string|null - */ - public function getConnection() - { - return config('passport.storage.database.connection'); + Schema::dropIfExists('oauth_personal_access_clients'); } } diff --git a/src/AuthCode.php b/src/AuthCode.php index 94441b5f7..09a79c826 100644 --- a/src/AuthCode.php +++ b/src/AuthCode.php @@ -68,14 +68,4 @@ public function client() { return $this->belongsTo(Passport::clientModel()); } - - /** - * Get the current connection name for the model. - * - * @return string|null - */ - public function getConnectionName() - { - return config('passport.storage.database.connection') ?? $this->connection; - } } diff --git a/src/Client.php b/src/Client.php index f75fb7b97..7313b40d8 100644 --- a/src/Client.php +++ b/src/Client.php @@ -184,16 +184,6 @@ public function getIncrementing() return Passport::clientUuids() ? false : $this->incrementing; } - /** - * Get the current connection name for the model. - * - * @return string|null - */ - public function getConnectionName() - { - return config('passport.storage.database.connection') ?? $this->connection; - } - /** * Create a new factory instance for the model. * diff --git a/src/PersonalAccessClient.php b/src/PersonalAccessClient.php index 1d35b0504..171b982ab 100644 --- a/src/PersonalAccessClient.php +++ b/src/PersonalAccessClient.php @@ -29,14 +29,4 @@ public function client() { return $this->belongsTo(Passport::clientModel()); } - - /** - * Get the current connection name for the model. - * - * @return string|null - */ - public function getConnectionName() - { - return config('passport.storage.database.connection') ?? $this->connection; - } } diff --git a/src/RefreshToken.php b/src/RefreshToken.php index 376a97b82..00e5a1c84 100644 --- a/src/RefreshToken.php +++ b/src/RefreshToken.php @@ -88,14 +88,4 @@ public function transient() { return false; } - - /** - * Get the current connection name for the model. - * - * @return string|null - */ - public function getConnectionName() - { - return config('passport.storage.database.connection') ?? $this->connection; - } } diff --git a/src/Token.php b/src/Token.php index 9dfd874c6..4a0a13d17 100644 --- a/src/Token.php +++ b/src/Token.php @@ -160,14 +160,4 @@ public function transient() { return false; } - - /** - * Get the current connection name for the model. - * - * @return string|null - */ - public function getConnectionName() - { - return config('passport.storage.database.connection') ?? $this->connection; - } } diff --git a/tests/Feature/PassportTestCase.php b/tests/Feature/PassportTestCase.php index d7da023cb..47a752fee 100644 --- a/tests/Feature/PassportTestCase.php +++ b/tests/Feature/PassportTestCase.php @@ -44,8 +44,6 @@ protected function getEnvironmentSetUp($app) $app['config']->set('database.default', 'testbench'); - $app['config']->set('passport.storage.database.connection', 'testbench'); - $app['config']->set('database.connections.testbench', [ 'driver' => 'sqlite', 'database' => ':memory:',