m160301_105759_chat.php
820 Bytes
<?php
use yii\db\Migration;
class m160301_105759_chat extends Migration
{
public function up()
{
$this->createTable('{{%chat}}', [
'chat_id' => $this->primaryKey(),
'status' => $this->string(),
'comment' => $this->string(),
'from_user' => $this->integer(),
'to_user' => $this->integer(),
]);
$this->addForeignKey('chat_from_user', '{{%chat}}', 'from_user', '{{%user}}', 'id', 'SET NULL', 'NO ACTION');
$this->addForeignKey('chat_to_user', '{{%chat}}', 'to_user', '{{%user}}', 'id', 'SET NULL', 'NO ACTION');
}
public function down()
{
$this->dropForeignKey('chat_from_user', '{{%chat}}');
$this->dropForeignKey('chat_to_user', '{{%chat}}');
$this->dropTable('{{%chat}}');
}
}