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

50 lines
1.3 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('album_view')->nullable();
$table->timestamp('hit_at');
$table->string('ip_address');
$table->string('user_agent');
$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');
}
}