<?php

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

    class CreateOccasionLanguages extends Migration
    {

        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::create('occasion_languages', function (Blueprint $table) {
                $table->bigIncrements('translation_id');
                $table->unsignedBigInteger('occasion_id');
                $table->string('language_id', 10);
                $table->string('title', 150);

                // Content
                $table->text('description');
                $table->string('excerpt', 200);

                // Metas
                $table->string('meta_title', 150)->nullable();
                $table->string('meta_description', 300)->nullable();

                // Languages
                $table->unique(['occasion_id', 'language_id'], 'idx_occasion_language');
                $table->foreign('occasion_id')
                    ->references('id')
                    ->on('occasions')
                    ->onDelete('CASCADE')
                    ->onUpdate('CASCADE');
            });
        }

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

    }
