<?php

use yii\db\Migration;

/**
 * Handles the creation of table `price_lang`.
 */
class m180524_152757_create_price_lang_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('price_lang', [
            'language_id' => $this->integer(),
            'price_id'  => $this->integer(),
            'title'       => $this->string(),
            'description' => $this->text()
        ]);
        
        $this->addPrimaryKey('price_lang_pk', 'price_lang', ['language_id', 'price_id']);
        
        $this->addForeignKey('price_lang_price_fk',
                            'price_lang',
                            'price_id',
                            'price',
                            'id',
                            'CASCADE',
                            'CASCADE');
        $this->addForeignKey('price_lang_language_fk',
                            'price_lang',
                            'language_id',
                            'language',
                            'id',
                            'CASCADE',
                            'CASCADE');
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropForeignKey('price_lang_price_fk', 'price_lang');
        $this->dropForeignKey('price_lang_language_fk', 'price_lang');
        $this->dropTable('price_lang');
    }
}
