<?php

use yii\db\Migration;

/**
 * Handles the creation for table `event_lang`.
 */
class m160928_161047_create_event_lang_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('event_lang', [
            'event_id'      => $this->integer()
                                       ->notNull(),
            'language_id'      => $this->integer()
                                       ->notNull(),
            'name'            => $this->string()
                                       ->notNull(),
            'body'             => $this->text()
                                       ->notNull(),
            'meta_title'       => $this->string(),
            'description' => $this->string(),
            'seo_text'         => $this->text(),
            'h1'               => $this->string(),
        ]);
        $this->createIndex('event_lang_event_language_key', 'event_lang', [
            'event_id',
            'language_id',
        ], true);
    
        $this->addForeignKey('event_fk', 'event_lang', 'event_id', 'event', 'event_id', 'CASCADE', 'CASCADE');
        $this->addForeignKey('language_fk', 'event_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('event_lang');
    }
}
