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

[11.x] Revert model DB connection customization #1412

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 0 additions & 17 deletions config/passport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
],
],

];
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,14 @@

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.
*
* @return void
*/
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');
Expand All @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,14 @@

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.
*
* @return void
*/
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');
Expand All @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,14 @@

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.
*
* @return void
*/
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');
Expand All @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,14 @@

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.
*
* @return void
*/
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');
Expand All @@ -61,6 +34,6 @@ public function up()
*/
public function down()
{
$this->schema->dropIfExists('oauth_clients');
Schema::dropIfExists('oauth_clients');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,14 @@

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.
*
* @return void
*/
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();
Expand All @@ -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');
}
}
10 changes: 0 additions & 10 deletions src/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
10 changes: 0 additions & 10 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 0 additions & 10 deletions src/PersonalAccessClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
10 changes: 0 additions & 10 deletions src/RefreshToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
10 changes: 0 additions & 10 deletions src/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 0 additions & 2 deletions tests/Feature/PassportTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:',
Expand Down