Blame view

console/migrations/m160930_100954_create_seo_lang_table.php 4.33 KB
d55d2fe0   Yarik   Multilanguage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  <?php
      
      use yii\db\Migration;
      
      /**
       * Handles the creation for table `seo_lang`.
       */
      class m160930_100954_create_seo_lang_table extends Migration
      {
          
          /**
           * @inheritdoc
           */
          public function up()
          {
4428da8c   Yarik   Almost all databa...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
              $this->createTable(
                  'seo_lang',
                  [
                      'seo_id'           => $this->integer()
                                                 ->notNull(),
                      'language_id'      => $this->integer()
                                                 ->notNull(),
                      'title'            => $this->string(),
                      'meta_description' => $this->text(),
                      'h1'               => $this->string(),
                      'meta'             => $this->string(),
                      'seo_text'         => $this->text(),
                  ]
              );
              $this->createIndex(
                  'seo_lang_seo_language_key',
                  'seo_lang',
                  [
                      'seo_id',
                      'language_id',
                  ],
                  true
              );
d55d2fe0   Yarik   Multilanguage
39
              
4428da8c   Yarik   Almost all databa...
40
              $this->addForeignKey('seo_fk', 'seo_lang', 'seo_id', 'seo', 'id', 'CASCADE', 'CASCADE');
8af13427   Yarik   For leha commit.
41
              $this->addForeignKey('language_fk', 'seo_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
4428da8c   Yarik   Almost all databa...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
              $this->createTable(
                  'seo_category_lang',
                  [
                      'seo_category_id' => $this->integer()
                                                ->notNull(),
                      'language_id'     => $this->integer()
                                                ->notNull(),
                      'title'           => $this->string(),
                  ]
              );
              $this->createIndex(
                  'seo_category_lang_seo_category_language_key',
                  'seo_category_lang',
                  [
                      'seo_category_id',
                      'language_id',
                  ],
                  true
              );
              
              $this->addForeignKey(
                  'seo_category_fk',
                  'seo_category_lang',
d55d2fe0   Yarik   Multilanguage
65
                  'seo_category_id',
4428da8c   Yarik   Almost all databa...
66
67
68
69
70
71
72
73
                  'seo_category',
                  'id',
                  'CASCADE',
                  'CASCADE'
              );
              $this->addForeignKey(
                  'language_fk',
                  'seo_category_lang',
d55d2fe0   Yarik   Multilanguage
74
                  'language_id',
4428da8c   Yarik   Almost all databa...
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
                  'language',
                  'id',
                  'RESTRICT',
                  'CASCADE'
              );
              $this->createTable(
                  'seo_dynamic_lang',
                  [
                      'seo_dynamic_id'   => $this->integer()
                                                 ->notNull(),
                      'language_id'      => $this->integer()
                                                 ->notNull(),
                      'title'            => $this->string(),
                      'meta_title'       => $this->text(),
                      'h1'               => $this->string(),
                      'key'              => $this->string(),
                      'meta'             => $this->string(),
                      'meta_description' => $this->text(),
                      'seo_text'         => $this->text(),
                  ]
              );
              $this->createIndex(
                  'seo_dynamic_lang_seo_dynamic_language_key',
                  'seo_dynamic_lang',
                  [
                      'seo_dynamic_id',
                      'language_id',
                  ],
                  true
              );
d55d2fe0   Yarik   Multilanguage
105
              
4428da8c   Yarik   Almost all databa...
106
107
108
              $this->addForeignKey(
                  'seo_dynamic_fk',
                  'seo_dynamic_lang',
d55d2fe0   Yarik   Multilanguage
109
                  'seo_dynamic_id',
4428da8c   Yarik   Almost all databa...
110
111
112
113
114
115
116
117
                  'seo_dynamic',
                  'id',
                  'CASCADE',
                  'CASCADE'
              );
              $this->addForeignKey(
                  'language_fk',
                  'seo_dynamic_lang',
d55d2fe0   Yarik   Multilanguage
118
                  'language_id',
4428da8c   Yarik   Almost all databa...
119
120
121
122
123
                  'language',
                  'id',
                  'RESTRICT',
                  'CASCADE'
              );
d55d2fe0   Yarik   Multilanguage
124
125
126
127
128
129
130
131
132
133
134
135
          }
          
          /**
           * @inheritdoc
           */
          public function down()
          {
              $this->dropTable('seo_lang');
              $this->dropTable('seo_category_lang');
              $this->dropTable('seo_dynamic_lang');
          }
      }