2019_03_06_065528_create_user_devices_table.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateUserDevicesTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('user_devices', function (Blueprint $table) {
  15. $table->bigIncrements('id');
  16. $table->bigInteger('user_id')->unsigned()->index();
  17. $table->string('ip')->index();
  18. $table->string('user_agent')->index();
  19. $table->string('fingerprint')->nullable();
  20. $table->string('name')->nullable();
  21. $table->boolean('trusted')->nullable();
  22. $table->timestamp('last_active_at')->nullable();
  23. $table->unique(['user_id', 'ip', 'user_agent', 'fingerprint'], 'user_ip_agent_index');
  24. $table->timestamps();
  25. });
  26. }
  27. /**
  28. * Reverse the migrations.
  29. *
  30. * @return void
  31. */
  32. public function down()
  33. {
  34. Schema::dropIfExists('user_devices');
  35. }
  36. }