Blame view

thread/modules/user/migrations/m160607_130950_insert_auth_item.php 2.15 KB
d1f8bd40   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  <?php
  
  use yii\db\Migration;
  use thread\modules\user\User as ParentModule;
  
  /**
   * Class m160607_130950_insert_auth_item
   *
   * @package thread\modules\user
   * @author FilamentV <vortex.filament@gmail.com>
   * @copyright (c) 2016, VipDesign
   */
  class m160607_130950_insert_auth_item extends Migration
  {
  
      /**
       * @var string
       */
      public $tableAuthItem = '{{%auth_item}}';
  
      /**
       * @var string
       */
      public $tableAuthAssignment = '{{%auth_assignment}}';
  
      /**
       * @var string
       */
      public $tableAuthItemChild = '{{%auth_item_child}}';
  
      /**
       *
       */
      public function init()
      {
          $this->db = ParentModule::getDb();
          parent::init();
      }
  
      /**
       * Implement migration
       */
      public function safeUp()
      {
          $this->batchInsert(
              $this->tableAuthItem,
              [
                  'name',
                  'type',
                  'description',
                  'rule_name',
                  'data',
                  'created_at',
                  'updated_at',
              ],
              [
                  [
                      'name' => 'dev',
                      'type' => 1,
                      'description' => 'developer',
                      'rule_name' => null,
                      'data' => null,
                      'created_at' => time(),
                      'updated_at' => time(),
                  ],
                  [
                      'name' => 'admin',
                      'type' => 1,
                      'description' => 'admin',
                      'rule_name' => null,
                      'data' => null,
                      'created_at' => time(),
                      'updated_at' => time(),
                  ],
                  [
                      'name' => 'user',
                      'type' => 1,
                      'description' => 'user',
                      'rule_name' => null,
                      'data' => null,
                      'created_at' => time(),
                      'updated_at' => time(),
                  ]
              ]
          );
      }
  
      /**
       * Cancel migration
       */
      public function safeDown()
      {
          //TODO: m160607_130950_insert_auth_item
      }
  }