Skip to content

Commit 128f99c

Browse files
authored
Merge pull request #1169 from KieronWiltshire/8.x
[8.x] Shouldn't the migrations use bigIncrements and indexes on relationships?
2 parents 4c163b7 + 46893d6 commit 128f99c

5 files changed

+14
-10
lines changed

database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ public function up()
1515
{
1616
Schema::create('oauth_auth_codes', function (Blueprint $table) {
1717
$table->string('id', 100)->primary();
18-
$table->bigInteger('user_id');
19-
$table->unsignedInteger('client_id');
18+
$table->bigInteger('user_id')->unsigned()->index();
19+
$table->bigInteger('client_id')->unsigned();
20+
$table->foreign('client_id')->references('id')->on('oauth_clients')->onDelete('cascade');
2021
$table->text('scopes')->nullable();
2122
$table->boolean('revoked');
2223
$table->dateTime('expires_at')->nullable();

database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ public function up()
1515
{
1616
Schema::create('oauth_access_tokens', function (Blueprint $table) {
1717
$table->string('id', 100)->primary();
18-
$table->bigInteger('user_id')->index()->nullable();
19-
$table->unsignedInteger('client_id');
18+
$table->bigInteger('user_id')->unsigned()->nullable()->index();
19+
$table->bigInteger('client_id')->unsigned();
20+
$table->foreign('client_id')->references('id')->on('oauth_clients')->onDelete('cascade');
2021
$table->string('name')->nullable();
2122
$table->text('scopes')->nullable();
2223
$table->boolean('revoked');

database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public function up()
1515
{
1616
Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
1717
$table->string('id', 100)->primary();
18-
$table->string('access_token_id', 100)->index();
18+
$table->string('access_token_id', 100);
19+
$table->foreign('access_token_id')->references('id')->on('oauth_access_tokens')->onDelete('cascade');
1920
$table->boolean('revoked');
2021
$table->dateTime('expires_at')->nullable();
2122
});

database/migrations/2016_06_01_000004_create_oauth_clients_table.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class CreateOauthClientsTable extends Migration
1414
public function up()
1515
{
1616
Schema::create('oauth_clients', function (Blueprint $table) {
17-
$table->increments('id');
18-
$table->bigInteger('user_id')->index()->nullable();
17+
$table->bigIncrements('id');
18+
$table->bigInteger('user_id')->unsigned()->nullable()->index();
1919
$table->string('name');
20-
$table->string('secret', 100)->nullable();
20+
$table->string('secret', 100);
2121
$table->text('redirect');
2222
$table->boolean('personal_access_client');
2323
$table->boolean('password_client');

database/migrations/2016_06_01_000005_create_oauth_personal_access_clients_table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ class CreateOauthPersonalAccessClientsTable extends Migration
1414
public function up()
1515
{
1616
Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
17-
$table->increments('id');
18-
$table->unsignedInteger('client_id')->index();
17+
$table->bigIncrements('id');
18+
$table->bigInteger('client_id')->unsigned();
19+
$table->foreign('client_id')->references('id')->on('oauth_clients')->onDelete('cascade');
1920
$table->timestamps();
2021
});
2122
}

0 commit comments

Comments
 (0)