<?php

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

class CreatePressReleaseLanguagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('press_release_languages', function (Blueprint $table) {
            $table->bigIncrements('translation_id');
            $table->unsignedBigInteger('press_release_id');
            $table->string('language_id', 10);
            $table->string('title', 150);
            $table->string('subtitle', 150)->nullable();
            $table->text('wysiwyg')->nullable();
            $table->string('intro', 500)->nullable();
            $table->string('label_banner', 100)->nullable();

            $table->unique(['press_release_id', 'language_id'], 'idx_press_release_lang');
            $table->foreign('press_release_id')
                ->references('id')
                ->on('press_releases')
                ->onDelete('CASCADE')
                ->onUpdate('CASCADE');
        });
    }
    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('press_release_languages');
    }
}
