Add UserDevice model

This commit is contained in:
Daniel Supernault 2019-03-06 00:55:03 -07:00
parent 94130fe14c
commit ad7f44e362
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
4 changed files with 90 additions and 1 deletions

View file

@ -0,0 +1,39 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserDevicesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_devices', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id')->unsigned()->index();
$table->string('ip')->index();
$table->string('user_agent')->index();
$table->string('fingerprint')->nullable();
$table->string('name')->nullable();
$table->boolean('trusted')->nullable();
$table->timestamp('last_active_at')->nullable();
$table->unique(['user_id', 'ip', 'user_agent', 'fingerprint'], 'user_ip_agent_index');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_devices');
}
}