1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace modules\users\migrations; |
4
|
|
|
|
5
|
|
|
use yii\db\Migration; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class m161022_180040_create_table_user |
9
|
|
|
* @package modules\users\migrations |
10
|
|
|
*/ |
11
|
|
|
class m161022_180040_create_table_user extends Migration |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @inheritdoc |
15
|
|
|
*/ |
16
|
|
|
public function safeUp() |
17
|
|
|
{ |
18
|
|
|
$tableOptions = null; |
19
|
|
|
if ($this->db->driverName === 'mysql') { |
20
|
|
|
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci |
21
|
|
|
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$this->createTable('{{%user}}', [ |
25
|
|
|
'id' => $this->primaryKey()->comment('ID'), |
26
|
|
|
'username' => $this->string()->notNull()->unique()->comment('Username'), |
27
|
|
|
'auth_key' => $this->string(32)->notNull()->comment('Authorization Key'), |
28
|
|
|
'password_hash' => $this->string()->notNull()->comment('Hash Password'), |
29
|
|
|
'password_reset_token' => $this->string()->unique()->comment('Password Token'), |
30
|
|
|
'email_confirm_token' => $this->string()->comment('Email Confirm Token'), |
31
|
|
|
'email' => $this->string()->notNull()->unique()->comment('Email'), |
32
|
|
|
'status' => $this->smallInteger()->notNull()->defaultValue(0)->comment('Status'), |
33
|
|
|
'last_visit' => $this->integer()->comment('Last Visit'), |
34
|
|
|
'created_at' => $this->integer()->notNull()->comment('Created'), |
35
|
|
|
'updated_at' => $this->integer()->notNull()->comment('Updated'), |
36
|
|
|
'first_name' => $this->string(45)->comment('First Name'), |
37
|
|
|
'last_name' => $this->string(45)->comment('Last Name'), |
38
|
|
|
'registration_type' => $this->integer()->defaultValue(0)->comment('Type Registration'), |
39
|
|
|
], $tableOptions); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @inheritdoc |
44
|
|
|
*/ |
45
|
|
|
public function safeDown() |
46
|
|
|
{ |
47
|
|
|
$this->dropTable('{{%user}}'); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|