Blame view

console/migrations/m160930_082350_create_project_lang_table.php 1.27 KB
d55d2fe0   Yarik   Multilanguage
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
  <?php
      
      use yii\db\Migration;
      
      /**
       * Handles the creation for table `project_lang`.
       */
      class m160930_082350_create_project_lang_table extends Migration
      {
          
          /**
           * @inheritdoc
           */
          public function up()
          {
              $this->createTable('project_lang', [
                  'project_id'  => $this->integer()
                                        ->notNull(),
                  'language_id' => $this->integer()
                                        ->notNull(),
                  'title'       => $this->string()
                                        ->notNull(),
                  'description' => $this->text(),
              ]);
              $this->createIndex('project_lang_project_language_key', 'project_lang', [
                  'project_id',
                  'language_id',
              ], true);
              
              $this->addForeignKey('project_fk', 'project_lang', 'project_id', 'project', 'project_id', 'CASCADE', 'CASCADE');
              $this->addForeignKey('language_fk', 'project_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
          }
          
          /**
           * @inheritdoc
           */
          public function down()
          {
              $this->dropTable('project_lang');
          }
      }