<?php

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

class CreateCopItemsLangTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cop_items_lang', function (Blueprint $table) {
            $table->increments('translation_id');
            $table->unsignedInteger('cop_item_id');
            $table->string('language_id', 10);
            $table->string('title', 150);
            $table->text('short_description')->nullable();
            $table->string('cta_desc', 255)->nullable();
            $table->string('source_url', 255)->nullable();
            $table->text('cta')->nullable();

            // Languages
            $table->unique(['cop_item_id', 'language_id'], 'idx_cop_items_lang');
            $table->foreign('cop_item_id')
                ->references('id')
                ->on('cop_items')
                ->onDelete('CASCADE')
                ->onUpdate('CASCADE');
        });
    }

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