<?php

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

class CreateChecklistsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('checklists', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('checklist_category_id');
            $table->string('title');
            $table->string('subtitle')->nullable();
        });

        Schema::table('checklists', function (Blueprint $table) {
            $table->foreign('checklist_category_id')->references('id')->on('checklist_categories');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('checklists', function (Blueprint $table) {
            $table->dropForeign('checklists_checklist_category_id_foreign');
        });

        Schema::dropIfExists('checklists');
    }
}
