<?php

use yii\db\Migration;

class m160804_100209_create_article_to_rating extends Migration
{
    public function up()
    {
        $this->createTable('article_to_rating', [
            'article_to_rating_id' => $this->primaryKey(),
            'articles_id' => $this->integer()->notNull(),
            'value' => $this->float()->defaultValue(0),
        ]);
    
        $this->addForeignKey('article_to_rating_article', 'article_to_rating', 'articles_id', 'articles', 'id', 'CASCADE', 'CASCADE');
    }

    public function down()
    {
        $this->dropForeignKey('article_to_rating_article', 'article_to_rating');
        $this->dropTable('article_to_rating');
    }
}
