Blame view

console/migrations/m160320_174258_customer.php 1.18 KB
3da83322   Administrator   21.03.16 Versrka
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  <?php
  
  use yii\db\Migration;
  
  class m160320_174258_customer extends Migration
  {
      public function up()
      {
          $tableOptions = null;
          if ($this->db->driverName === 'mysql') {
              // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
              $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
          }
  
          $this->createTable('{{%customers}}', [
              'id' => $this->primaryKey(),
cea5c45d   Administrator   21.03.16 Versrka
17
              'username' => $this->string()->notNull(),
3da83322   Administrator   21.03.16 Versrka
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
              'surname' => $this->string(),
              'auth_key' => $this->string(32)->notNull(),
              'password_hash' => $this->string()->notNull(),
              'password_reset_token' => $this->string()->unique(),
              'email' => $this->string()->notNull()->unique(),
              'phone' => $this->string()->notNull()->unique(),
              'status' => $this->smallInteger()->notNull()->defaultValue(10),
              'created_at' => $this->integer()->notNull(),
              'updated_at' => $this->integer()->notNull(),
          ], $tableOptions);
      }
  
      public function down()
      {
          $this->dropTable('{{%customers}}');
      }
  
  }