cleric.test/migrations/m0000000_init.php

61 lines
1.9 KiB
PHP

<?php
use yii\db\Migration;
use yii\db\Schema;
class m0000000_init extends Migration
{
public function safeUp()
{
$this->createTable('user', [
'id' => Schema::TYPE_PK,
'name' => Schema::TYPE_TEXT . ' NOT NULL',
'login' => Schema::TYPE_TEXT . ' NOT NULL',
'phone' => Schema::TYPE_TEXT . ' NOT NULL',
'avatar' => Schema::TYPE_TEXT,
'website' => Schema::TYPE_TEXT,
'passHash' => Schema::TYPE_TEXT,
'accessToken' => Schema::TYPE_TEXT
]);
$this->createTable('materials', [
'id' => Schema::TYPE_PK,
'title' => Schema::TYPE_TEXT . ' NOT NULL',
'content' => Schema::TYPE_TEXT . ' NOT NULL',
'blog_id' => Schema::TYPE_BIGINT,
]);
$this->createTable('companies', [
'id' => Schema::TYPE_PK,
'title' => Schema::TYPE_TEXT . ' NOT NULL',
'website' => Schema::TYPE_TEXT . ' NOT NULL',
'address' => Schema::TYPE_TEXT . ' NOT NULL',
'blog_id' => Schema::TYPE_BIGINT,
]);
$this->createTable('blogs', [
'id' => Schema::TYPE_PK
]);
$this->createTable('subscriptions', [
'user_id' => Schema::TYPE_BIGINT . ' NOT NULL',
'blog_id' => Schema::TYPE_BIGINT . ' NOT NULL',
]);
$this->createTable('comments', [
'user_id' => Schema::TYPE_BIGINT . ' NOT NULL',
'material_id' => Schema::TYPE_BIGINT . ' NOT NULL',
'content' => Schema::TYPE_TEXT . ' NOT NULL',
]);
}
public function safeDown()
{
$this->dropTable('user');
$this->dropTable('materials');
$this->dropTable('companies');
$this->dropTable('blogs');
$this->dropTable('subscriptions');
$this->dropTable('comments');
}
}