Blame view

console/migrations/m170309_000002_language.php 2.43 KB
81add67c   alex   first
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
  <?php
      
      use yii\db\Migration;
      
      class m170309_000002_language extends Migration
      {
          public function safeUp()
          {
              $this->createTable(
                  'language',
                  [
                      'id'         => $this->primaryKey(),
                      'url'        => $this->string(255)
                                           ->notNull(),
                      'local'      => $this->string(255)
                                           ->notNull(),
                      'name'       => $this->string(255)
                                           ->notNull(),
                      'default'    => $this->boolean()
                                           ->notNull()
                                           ->defaultValue(false),
                      'created_at' => $this->integer(32)
                                           ->notNull(),
                      'updated_at' => $this->integer(32)
                                           ->notNull(),
                      'status'     => $this->boolean()
                                           ->notNull()
                                           ->defaultValue(false),
                  ]
              );
              
              $this->batchInsert(
                  'language',
                  [
                      'url',
                      'local',
                      'name',
                      'default',
                      'created_at',
                      'updated_at',
                      'status',
                  ],
                  [
                      [
                          'en',
                          'en-EN',
                          'English',
                          true,
                          0,
                          0,
                          true,
                      ],
                      [
                          'ru',
                          'ru-RU',
                          'Русский',
                          false,
                          0,
                          0,
                          true,
                      ],
                      [
                          'ua',
                          'ua-UA',
                          'Українська',
                          false,
                          0,
                          0,
                          false,
                      ],
                  ]
              );
          }
          
          public function safeDown()
          {
              $this->dropTable('language');
          }
      }