Skip to content

Commit

Permalink
Nullable user_id and api_log table now has a user_id
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbjr committed Feb 21, 2016
1 parent 04ca21b commit ded454d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions database/migrations/2015_03_02_031822_create_api_keys_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up()
{
Schema::create('api_keys', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('user_id', false, true)->nullable();
$table->string('key', 40);
$table->smallInteger('level');
$table->boolean('ignore_limits');
Expand All @@ -25,22 +25,32 @@ public function up()
// unique key
$table->unique('key');

// Uncomment this if you want to link user ids to your users table
//$table->foreign('user_id')->references('id')->on('users');
// Let's index the user ID just in case you don't set it as a foreign key
$table->index('user_id');

// Uncomment the line below if you want to link user ids to your users table
//$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');;
});

Schema::create('api_logs', function (Blueprint $table) {
$table->increments('id');
$table->integer('api_key_id', false, true)->nullable();
$table->string('route', 150);
$table->integer('user_id', false, true)->nullable();
$table->string('route', 255);
$table->string('method', 6);
$table->text('params');
$table->string('ip_address');
$table->nullableTimestamps();

$table->foreign('api_key_id')->references('id')->on('api_keys');
$table->index('route');
$table->index('method');
$table->foreign('api_key_id')->references('id')->on('api_keys');

// Let's index the user ID just in case you don't set it as a foreign key
$table->index('user_id');

// Uncomment the line below if you want to link user ids to your users table
//$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');;
});
}

Expand Down

0 comments on commit ded454d

Please sign in to comment.