Blame view

console/migrations/m170309_000003_alias.php 1.48 KB
c237629a   Anastasia   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
  <?php
      
      use yii\db\Migration;
      
      class m170309_000003_alias extends Migration
      {
          public function safeUp()
          {
              $this->createTable(
                  'alias',
                  [
                      'id'          => $this->primaryKey(),
                      'value'       => $this->string()
                                            ->notNull(),
                      'route'       => $this->string(),
                      'title'       => $this->string(),
                      'description' => $this->text(),
                      'h1'          => $this->string(),
                      'robots'      => $this->string(),
                      'seo_text'    => $this->text(),
                      'entity'      => $this->string(),
                      'fields'=> $this->text(),
                      'language_id'=>  $this->integer()
                  ]
              );
      
              $this->addForeignKey('alias_to_language', 'alias', 'language_id', 'language', 'id', 'SET NULL', 'CASCADE');
      
              $this->createIndex(
                  'alias_value_language_id_uix',
                  'alias',
                  [
                      'value',
                      'language_id',
                  ],
                  true
              );
          }
          
          public function safeDown()
          {
              $this->dropForeignKey('alias_to_language', 'alias');
              $this->dropIndex('alias_value_language_id_uix', 'alias');
              $this->dropTable('alias');
          }
      }