forked from cebe/yii2-openapi
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathm200000_000001_create_table_users.php
More file actions
31 lines (29 loc) · 1.14 KB
/
m200000_000001_create_table_users.php
File metadata and controls
31 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* Table for User
*/
class m200000_000001_create_table_users extends \yii\db\Migration
{
public function up()
{
$this->createTable('{{%users}}', [
'id' => $this->primaryKey(),
'username' => $this->string(200)->notNull(),
'email' => $this->string(200)->notNull(),
'password' => $this->string()->notNull(),
'role' => $this->string(20)->notNull()->defaultValue('reader'),
'flags' => $this->integer()->notNull()->defaultValue(0),
'created_at' => $this->timestamp()->notNull()->defaultExpression("(CURRENT_TIMESTAMP)"),
]);
$this->createIndex('users_username_key', '{{%users}}', 'username', true);
$this->createIndex('users_email_key', '{{%users}}', 'email', true);
$this->createIndex('users_role_flags_index', '{{%users}}', ["role", "flags"], false);
}
public function down()
{
$this->dropIndex('users_role_flags_index', '{{%users}}');
$this->dropIndex('users_email_key', '{{%users}}');
$this->dropIndex('users_username_key', '{{%users}}');
$this->dropTable('{{%users}}');
}
}