<?php

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

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

            $table->unsignedBigInteger('backend_user_id')->nullable();
            $table->foreign('backend_user_id')->references('id')
                ->on('backend_users')->onDelete('SET NULL')->onUpdate('CASCADE');

            $table->unsignedBigInteger('property_id')->nullable();
            $table->foreign('property_id')->references('id')
                ->on('properties')->onDelete('SET NULL')->onUpdate('CASCADE');

            $table->unsignedBigInteger('epigraph_id')->nullable();
            $table->foreign('epigraph_id')->references('id')
                ->on('epigraphs')->onDelete('SET NULL')->onUpdate('CASCADE');

            $table->unsignedBigInteger('external_id')->nullable()->unique();

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

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