<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShareStatsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('share_stats', function (Blueprint $table) {
            $table->bigIncrements('id');

            $table->bigInteger('web_views')->default(0);
            $table->bigInteger('download_views')->default(0);

            $table->unsignedInteger('capsule_id')->nullable();

            $table->foreign('capsule_id')->references('id')->on('table_capsule')->onDelete('cascade');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('share_stats');
    }
}
