<?php

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

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

        Schema::table('filter_items', function (Blueprint $table) {
            $table->foreign('filter_id')->references('id')->on('filters');
        });
    }

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

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