m160413_112158_create_seo_dynamic.php 1.08 KB
<?php

use yii\db\Migration;

/**
 * Handles the creation for table `seo_dynamic`.
 */
class m160413_112158_create_seo_dynamic extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('seo_dynamic', [
            'seo_dynamic_id' => $this->primaryKey(),
            'seo_category_id' => $this->integer(),
            'name' => $this->string(200),
            'action' => $this->string(200),
            'fields' => $this->string(),
            'title' => $this->string(),
            'h1' => $this->string(),
            'description' => $this->string(),
            'seo_text' => $this->text(),
            'status' => $this->smallInteger()
        ]);

        $this->addForeignKey('seo_category_seo_dynamic_fk', 'seo_dynamic', 'seo_category_id', 'seo_category', 'seo_category_id', 'CASCADE', 'CASCADE');
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropForeignKey('seo_category_seo_dynamic_fk', '{{%seo_dynamic}}');
        $this->dropTable('seo_dynamic');
    }
}