m150828_085134_init_user_tables   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 22 2
A down() 0 4 1
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * Class m150828_085134_init_user_tables
7
 */
8
class m150828_085134_init_user_tables extends Migration
9
{
10
    public function up()
11
    {
12
        $tableOptions = null;
13
14
        if ($this->db->driverName === 'mysql') {
15
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
16
        }
17
18
        // Create user table
19
        $this->createTable('{{%User}}', [
20
            'id' => $this->primaryKey(),
21
            'username' => $this->string()->notNull()->unique(),
22
            'authKey' => $this->string(32)->notNull(),
23
            'passwordHash' => $this->string()->notNull(),
24
            'passwordResetToken' => $this->string()->unique(),
25
            'email' => $this->string()->notNull()->unique(),
26
            'status' => $this->smallInteger()->notNull()->defaultValue(1),
27
            'createdAt' => $this->integer()->notNull(),
28
            'updatedAt' => $this->integer()->notNull(),
29
            'lastLogin' => $this->integer(),
30
        ], $tableOptions);
31
    }
32
33
    public function down()
34
    {
35
        $this->dropTable('{{%User}}');
36
    }
37
38
    /*
39
    // Use safeUp/safeDown to run migration code within a transaction
40
    public function safeUp()
41
    {
42
    }
43
44
    public function safeDown()
45
    {
46
    }
47
    */
48
}
49