<?php
    
    use yii\db\Migration;
    
    /**
     * Handles the creation of table `ImageManagerLang`.
     */
    class m170619_095632_create_ImageManagerLang_table extends Migration
    {
        /**
         * @inheritdoc
         */
        public function up()
        {
            $this->createTable(
                'ImageManagerLang',
                [
                    'image_id'    => $this->integer(),
                    'language_id' => $this->integer(),
                    'title'       => $this->string(),
                    'alt'         => $this->string(),
                    'description' => $this->string(),
                ]
            );
            
            $this->addForeignKey(
                'image_fk',
                'ImageManagerLang',
                'image_id',
                'ImageManager',
                'id',
                'CASCADE',
                'CASCADE'
            );
            
            $this->addForeignKey(
                'language_fk',
                'ImageManagerLang',
                'language_id',
                'language',
                'id',
                'CASCADE',
                'CASCADE'
            );
            
            $this->createIndex(
                'img_lang_uk',
                'ImageManagerLang',
                [
                    'language_id',
                    'image_id',
                ],
                true
            );
        }
        
        /**
         * @inheritdoc
         */
        public function down()
        {
            $this->dropTable('ImageManagerLang');
        }
    }
