<?php

use yii\db\Migration;

class m160311_132124_rating_comment_restyle extends Migration
{
    public function up()
    {
        $this->truncateTable('{{%comment}}');
        $this->truncateTable('{{%rating}}');
        $this->dropColumn('{{%comment}}', 'entity');
        $this->dropColumn('{{%rating}}', 'entity');
        $this->addColumn('{{%comment}}', 'model', $this->string()->notNull());
        $this->addColumn('{{%comment}}', 'model_id', $this->integer()->notNull());
        $this->addColumn('{{%rating}}', 'model', $this->string()->notNull());
        $this->addColumn('{{%rating}}', 'model_id', $this->integer()->notNull());
    }

    public function down()
    {
        $this->truncateTable('{{%comment}}');
        $this->truncateTable('{{%rating}}');
        $this->dropColumn('{{%comment}}', 'model');
        $this->dropColumn('{{%rating}}', 'model');
        $this->dropColumn('{{%comment}}', 'model_id');
        $this->dropColumn('{{%rating}}', 'model_id');
        $this->addColumn('{{%comment}}', 'entity', $this->string()->notNull());
        $this->addColumn('{{%rating}}', 'entity', $this->string()->notNull());
    }

}
