From 676fb4c06ad54d6b98bbc862c4dac147b8602d1b Mon Sep 17 00:00:00 2001 From: Daniel Tse Date: Thu, 11 Dec 2014 15:50:42 -0700 Subject: [PATCH 1/2] Fix column declarations and references so that foreign keys and references work. --- examples/relational/config/init.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/relational/config/init.php b/examples/relational/config/init.php index 1c07630f..eb404a88 100644 --- a/examples/relational/config/init.php +++ b/examples/relational/config/init.php @@ -102,7 +102,7 @@ Capsule::table('oauth_scopes')->insert([ print 'Creating sessions table'.PHP_EOL; Capsule::schema()->create('oauth_sessions', function ($table) { - $table->increments('id'); + $table->increments('id')->unsigned(); $table->string('owner_type'); $table->string('owner_id'); $table->string('client_id'); @@ -135,7 +135,7 @@ print 'Creating access tokens table'.PHP_EOL; Capsule::schema()->create('oauth_access_tokens', function ($table) { $table->string('access_token')->primary(); - $table->integer('session_id'); + $table->integer('session_id')->unsigned(); $table->integer('expire_time'); $table->foreign('session_id')->references('id')->on('oauth_sessions')->onDelete('cascade'); @@ -168,7 +168,7 @@ Capsule::schema()->create('oauth_refresh_tokens', function ($table) { $table->integer('expire_time'); $table->string('access_token'); - $table->foreign('access_token')->references('id')->on('oauth_access_tokens')->onDelete('cascade'); + $table->foreign('access_token')->references('access_token')->on('oauth_access_tokens')->onDelete('cascade'); }); /******************************************************************************/ @@ -177,7 +177,7 @@ print 'Creating auth codes table'.PHP_EOL; Capsule::schema()->create('oauth_auth_codes', function ($table) { $table->string('auth_code')->primary(); - $table->integer('session_id'); + $table->integer('session_id')->unsigned(); $table->integer('expire_time'); $table->string('client_redirect_uri'); @@ -189,7 +189,7 @@ Capsule::schema()->create('oauth_auth_codes', function ($table) { print 'Creating oauth access token scopes table'.PHP_EOL; Capsule::schema()->create('oauth_access_token_scopes', function ($table) { - $table->increments('id'); + $table->increments('id')->unsigned(); $table->string('access_token'); $table->string('scope'); @@ -240,8 +240,8 @@ Capsule::schema()->create('oauth_auth_code_scopes', function ($table) { print 'Creating oauth session scopes table'.PHP_EOL; Capsule::schema()->create('oauth_session_scopes', function ($table) { - $table->increments('id'); - $table->string('session_id'); + $table->increments('id')->unsigned(); + $table->string('session_id')->unsigned(); $table->string('scope'); $table->foreign('session_id')->references('id')->on('oauth_sessions')->onDelete('cascade'); From 2653a174bb375d694bebc701123f82f47279cfa4 Mon Sep 17 00:00:00 2001 From: Daniel Tse Date: Fri, 12 Dec 2014 10:25:52 -0700 Subject: [PATCH 2/2] Update init.php --- examples/relational/config/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/relational/config/init.php b/examples/relational/config/init.php index eb404a88..85ba40f0 100644 --- a/examples/relational/config/init.php +++ b/examples/relational/config/init.php @@ -241,7 +241,7 @@ print 'Creating oauth session scopes table'.PHP_EOL; Capsule::schema()->create('oauth_session_scopes', function ($table) { $table->increments('id')->unsigned(); - $table->string('session_id')->unsigned(); + $table->integer('session_id')->unsigned(); $table->string('scope'); $table->foreign('session_id')->references('id')->on('oauth_sessions')->onDelete('cascade');