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