Passed
Push — master ( 620198...96468c )
by Wilmer
02:04
created

m000000_000001_create_user_table::up()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 15
nc 2
nop 0
dl 0
loc 21
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
use yii\db\Migration;
4
5
/**
6
 * m000000_000001_create_user_table is the migrations Web Application Basic.
7
 **/
8
class m000000_000001_create_user_table extends Migration
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
	public function up()
14
	{
15
		$tableOptions = null;
16
17
		if ($this->db->driverName === 'mysql') {
18
			// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
19
			$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
20
		}
21
22
		$this->createTable('{{%user}}', [
23
			'id' =>$this->primaryKey(),
24
			'username' =>$this->string()->notNull()->unique(),
25
			'auth_key' =>$this->string(32)->notNull(),
26
			'password_hash' =>$this->string()->notNull(),
27
			'password_reset_token' =>$this->string()->unique(),
28
            'email' =>$this->string()->notNull()->unique(),
29
            'role' =>$this->smallInteger()->notNull()->defaultValue(10),
30
			'status' =>$this->smallInteger()->notNull()->defaultValue(10),
31
			'created_at' =>$this->integer()->notNull(),
32
			'updated_at' =>$this->integer()->notNull(),
33
		], $tableOptions);
34
	}
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
	public function down()
40
	{
41
		$this->dropTable('{{%user}}');
42
	}
43
}
44