<?php

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

class CreateAudioVisualLanguagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('audio_visual_languages', function (Blueprint $table) {
            $table->bigIncrements('translation_id');
            
            $table->unsignedBigInteger('audio_visual_id');
            $table->string('language_id', 10);
            
            $table->string('title', 150)->nullable();
            $table->string('link', 250)->nullable();
            $table->string('type', 20)->nullable();
            $table->string('image', 255);
            
            $table->unique(['audio_visual_id', 'language_id'], 'idx_audio_visual_lang');
            $table->foreign('audio_visual_id')
                ->references('id')
                ->on('audio_visuals')
                ->onDelete('CASCADE')
                ->onUpdate('CASCADE');
            
            $table->timestamps();
        });
    }

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