Passed
Push — master ( dea94f...632371 )
by Wilmer
01:59
created

m000000_000001_create_user_table::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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