Skip to content

Commit

Permalink
[10.x] Fix migrations for Laravel 9.x (#1639)
Browse files Browse the repository at this point in the history
* fix migrations

* style fix

* style fix
  • Loading branch information
ricky-perchpeek committed Feb 21, 2023
1 parent 75fd509 commit 4bfdb96
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,18 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
return new class() 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 = Schema::connection($this->getConnection());

$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,7 +32,9 @@ public function up()
*/
public function down()
{
$this->schema->dropIfExists('oauth_auth_codes');
$schema = Schema::connection($this->getConnection());

$schema->dropIfExists('oauth_auth_codes');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,18 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
return new class() 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 = Schema::connection($this->getConnection());

$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,7 +34,9 @@ public function up()
*/
public function down()
{
$this->schema->dropIfExists('oauth_access_tokens');
$schema = Schema::connection($this->getConnection());

$schema->dropIfExists('oauth_access_tokens');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,18 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
return new class() 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 = Schema::connection($this->getConnection());

$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,7 +30,9 @@ public function up()
*/
public function down()
{
$this->schema->dropIfExists('oauth_refresh_tokens');
$schema = Schema::connection($this->getConnection());

$schema->dropIfExists('oauth_refresh_tokens');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
return new class() 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.
*
Expand All @@ -40,7 +23,9 @@ public function getConnection()
*/
public function up()
{
$this->schema->create('oauth_clients', function (Blueprint $table) {
$schema = Schema::connection($this->getConnection());

$schema->create('oauth_clients', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id')->nullable()->index();
$table->string('name');
Expand All @@ -61,6 +46,8 @@ public function up()
*/
public function down()
{
$this->schema->dropIfExists('oauth_clients');
$schema = Schema::connection($this->getConnection());

$schema->dropIfExists('oauth_clients');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,18 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
return new class() 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 = Schema::connection($this->getConnection());

$schema->create('oauth_personal_access_clients', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('client_id');
$table->timestamps();
Expand All @@ -44,7 +29,9 @@ public function up()
*/
public function down()
{
$this->schema->dropIfExists('oauth_personal_access_clients');
$schema = Schema::connection($this->getConnection());

$schema->dropIfExists('oauth_personal_access_clients');
}

/**
Expand Down

0 comments on commit 4bfdb96

Please sign in to comment.