m160316_134249_bookmarks_table.php
963 Bytes
<?php
use yii\db\Migration;
class m160316_134249_bookmarks_table extends Migration
{
public function up()
{
$this->createTable('{{%bookmark}}', [
'bookmark_id' => $this->primaryKey(),
'user_id' => $this->integer()
->notNull(),
'model' => $this->string()
->notNull(),
'model_id' => $this->integer()
->notNull(),
'type' => $this->integer()
->notNull(),
]);
$this->addForeignKey('bookmark_user', '{{%bookmark}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE');
}
public function down()
{
$this->dropForeignKey('bookmark_user', '{{%bookmark}}');
$this->dropTable('{{%bookmark}}');
}
}