<?php
    
    use yii\db\Migration;
    
    /**
     * Handles the creation for table `orders_label_lang`.
     */
    class m160929_142458_create_orders_label_lang_table extends Migration
    {
        
        /**
         * @inheritdoc
         */
        public function up()
        {
            $this->createTable('orders_label_lang', [
                'orders_label_id' => $this->integer()
                                          ->notNull(),
                'language_id'     => $this->integer()
                                          ->notNull(),
                'name'            => $this->string()
                                          ->notNull(),
            ]);
            $this->createIndex('orders_label_lang_orders_label_language_key', 'orders_label_lang', [
                'orders_label_id',
                'language_id',
            ], true);
            
            $this->addForeignKey('orders_label_fk', 'orders_label_lang', 'orders_label_id', 'orders_label', 'id', 'CASCADE', 'CASCADE');
            $this->addForeignKey('language_fk', 'orders_label_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
        }
        
        /**
         * @inheritdoc
         */
        public function down()
        {
            $this->dropTable('orders_label_lang');
        }
    }
