<?php
    
    use yii\db\Migration;
    
    /**
     * Handles the creation for table `banner_lang`.
     */
    class m160928_104529_create_banner_lang_table extends Migration
    {
        
        /**
         * @inheritdoc
         */
        public function up()
        {
            $this->createTable('banner_lang', [
                'banner_id'   => $this->integer()
                                      ->notNull(),
                'language_id' => $this->integer()
                                      ->notNull(),
                'alt'         => $this->string(),
                'title'       => $this->string(),
            ]);
            
            $this->createIndex('banner_lang_banner_language_key', 'banner_lang', [
                'banner_id',
                'language_id',
            ], true);
            
            $this->addForeignKey('banner_fk', 'banner_lang', 'banner_id', 'banner', 'banner_id', 'CASCADE', 'CASCADE');
            $this->addForeignKey('language_fk', 'banner_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
        }
        
        /**
         * @inheritdoc
         */
        public function down()
        {
            $this->dropTable('banner_lang');
        }
    }
