Blame view

console/migrations/m150929_110456_addTempTableUser.php 1.51 KB
fe1397b3   Administrator   Merge branch 'mas...
1
2
3
4
5
  <?php
  
  use yii\db\Schema;
  use yii\db\Migration;
  
df629228   Mihail   console csv parsing
6
  class m150929_110456_addTempTableUser extends Migration
fe1397b3   Administrator   Merge branch 'mas...
7
8
9
10
11
12
13
14
15
  {
      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';
          }
  
df629228   Mihail   console csv parsing
16
          $this->createTable('user', [
fe1397b3   Administrator   Merge branch 'mas...
17
18
19
20
21
22
23
24
25
26
27
              'id' => $this->primaryKey(),
              'username' => $this->string()->notNull()->unique(),
              'auth_key' => $this->string(32)->notNull(),
              'password_hash' => $this->string()->notNull(),
              'password_reset_token' => $this->string()->unique(),
              'email' => $this->string()->notNull()->unique(),
  
              'status' => $this->smallInteger()->notNull()->defaultValue(10),
              'created_at' => $this->integer()->notNull(),
              'updated_at' => $this->integer()->notNull(),
          ], $tableOptions);
df629228   Mihail   console csv parsing
28
29
30
31
32
33
34
35
36
37
38
39
  
          $user_array = [
              'username' => 'admin',
              'auth_key' => 'admin',
              'password_hash' => Yii::$app->security->generatePasswordHash('admin'),
              'password_reset_token' => 'admin',
              'email'=> 'admin@test.com',
              'status' => '10',
              'created_at'=>'000000',
              'updated_at' => '000000'
          ];
          $this->insert('user', $user_array);
fe1397b3   Administrator   Merge branch 'mas...
40
41
42
43
      }
  
      public function down()
      {
df629228   Mihail   console csv parsing
44
          $this->dropTable('user');
fe1397b3   Administrator   Merge branch 'mas...
45
46
      }
  }