<?php
    
    use yii\db\Migration;
    
    /**
     * Handles the creation for table `orders_delivery_lang`.
     */
    class m160929_135920_create_orders_delivery_lang_table extends Migration
    {
        
        /**
         * @inheritdoc
         */
        public function up()
        {
            $this->createTable('orders_delivery_lang', [
                'orders_delivery_id' => $this->integer()
                                             ->notNull(),
                'language_id'        => $this->integer()
                                             ->notNull(),
                'title'              => $this->string()
                                             ->notNull(),
                'text'               => $this->text()
                                             ->notNull(),
            ]);
            $this->createIndex('orders_delivery_lang_orders_delivery_language_key', 'orders_delivery_lang', [
                'orders_delivery_id',
                'language_id',
            ], true);
            
            $this->addForeignKey('orders_delivery_fk', 'orders_delivery_lang', 'orders_delivery_id', 'orders_delivery', 'id', 'CASCADE', 'CASCADE');
            $this->addForeignKey('language_fk', 'orders_delivery_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
        }
        
        /**
         * @inheritdoc
         */
        public function down()
        {
            $this->dropTable('orders_delivery');
        }
    }
