m160314_090858_project_comment.php
1.39 KB
<?php
use yii\db\Migration;
class m160314_090858_project_comment extends Migration
{
public function up()
{
$this->createTable('{{%comment_project}}', [
'comment_id' => $this->primaryKey(),
'model' => $this->string()->notNull(),
'model_id' => $this->integer()->notNull(),
'text' => $this->text()->notNull(),
'files' => $this->string(),
'budget_from' => $this->float()->notNull()->defaultValue(0),
'budget_to' => $this->float()->notNull()->defaultValue(0),
'budget_currency' => $this->integer()->notNull()->defaultValue(3),
'term_from' => $this->integer()->notNull()->defaultValue(0),
'term_to' => $this->integer()->notNull()->defaultValue(0),
'user_id' => $this->integer()->notNull(),
'status' => $this->integer(),
'date_add' => $this->timestamp()->notNull()->defaultExpression('NOW()'),
'date_update' => $this->timestamp()->notNull()->defaultExpression('NOW()'),
'date_delete' => $this->timestamp(),
]);
$this->addForeignKey('comment_project_user', '{{%comment_project}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE');
}
public function down()
{
$this->dropForeignKey('comment_project_user', '{{%comment_project}}');
$this->dropTable('{{%comment_project}}');
}
}