blue-twilight/database/migrations/2017_04_16_095641_create_vi...

52 lines
1.4 KiB
PHP

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateVisitorHitsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('visitor_hits', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedInteger('album_id')->nullable();
$table->unsignedBigInteger('photo_id')->nullable();
$table->unsignedInteger('user_id')->nullable();
$table->string('view_style')->nullable();
$table->timestamp('hit_at');
$table->string('ip_address');
$table->string('user_agent');
$table->string('session_identifier');
$table->string('uri', 500);
$table->foreign('album_id')
->references('id')->on('albums')
->onDelete('no action');
$table->foreign('photo_id')
->references('id')->on('photos')
->onDelete('no action');
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('no action');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('visitor_hits');
}
}