Total Complexity | 5 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6 | class m160312_050000_create_user extends Migration |
||
7 | { |
||
8 | |||
9 | public function up() |
||
10 | { |
||
11 | $tableOptions = null; |
||
12 | if ($this->db->driverName === 'mysql') { |
||
13 | // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci |
||
14 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
||
15 | } |
||
16 | |||
17 | $userTable = Configs::instance()->userTable; |
||
18 | $db = Configs::userDb(); |
||
19 | |||
20 | // Check if the table exists |
||
21 | if ($db->schema->getTableSchema($userTable, true) === null) { |
||
22 | $this->createTable($userTable, [ |
||
23 | 'id' => $this->primaryKey(), |
||
24 | 'username' => $this->string(32)->notNull(), |
||
25 | 'auth_key' => $this->string(32)->notNull(), |
||
26 | 'password_hash' => $this->string()->notNull(), |
||
27 | 'password_reset_token' => $this->string(), |
||
28 | 'email' => $this->string()->notNull(), |
||
29 | 'status' => $this->smallInteger()->notNull()->defaultValue(10), |
||
30 | 'created_at' => $this->integer()->notNull(), |
||
31 | 'updated_at' => $this->integer()->notNull(), |
||
32 | ], $tableOptions); |
||
33 | } |
||
34 | } |
||
35 | |||
36 | public function down() |
||
42 | } |
||
43 | } |
||
45 |