<?php

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

class CreateStickyCtas extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sticky_ctas', function (Blueprint $table) {
            // General
            $table->integerIncrements('id');
            $table->unsignedInteger('backend_user_id')->nullable();
            $table->foreign('backend_user_id')->references('id')
                ->on('backend_users')->onDelete('SET NULL')->onUpdate('CASCADE');
            $table->nullableTimestamps();
            $table->unsignedInteger('image_id')->nullable();
            $table->unsignedInteger('icon_id')->nullable();
            $table->string('color_scheme', 30)->nullable();

            $table->foreign('image_id')->references('id')
                ->on('media_items')->onDelete('SET NULL')->onUpdate('CASCADE');

            $table->foreign('icon_id')->references('id')
                ->on('media_items')->onDelete('SET NULL')->onUpdate('CASCADE');
        });
    }

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