<?php

use yii\db\Migration;

/**
 * Handles the creation for table `bg_lang`.
 */
class m160928_112124_create_bg_lang_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('bg_lang', [
            'bg_id'   => $this->integer()
                                  ->notNull(),
            'language_id' => $this->integer()
                                  ->notNull(),
            'title'       => $this->string()->notNull(),
        ]);
        
        $this->createIndex('bg_lang_bg_language_key', 'bg_lang', [
            'bg_id',
            'language_id',
        ], true);
    
        $this->addForeignKey('bg_fk', 'bg_lang', 'bg_id', 'bg', 'id', 'CASCADE', 'CASCADE');
        $this->addForeignKey('language_fk', 'bg_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
    }

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