<?php

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

class CreateCheckinWebhooksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('checkin_webhooks', function (Blueprint $table) {
            $table->string('id', 64);
            $table->integer('user_id')->nullable();
            $table->string('name');
            $table->timestamps();
            $table->softDeletes();

            $table->primary('id');
            $table->index('user_id');

            $table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
        });
    }

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