Blame view

console/migrations/m161011_104931_create_stock_lang_table.php 1.33 KB
e8ccb1b4   Yarik   Import beta
1
  <?php
4428da8c   Yarik   Almost all databa...
2
3
4
      
      use yii\db\Migration;
      
e8ccb1b4   Yarik   Import beta
5
      /**
4428da8c   Yarik   Almost all databa...
6
       * Handles the creation for table `stock_lang`.
e8ccb1b4   Yarik   Import beta
7
       */
4428da8c   Yarik   Almost all databa...
8
      class m161011_104931_create_stock_lang_table extends Migration
e8ccb1b4   Yarik   Import beta
9
      {
4428da8c   Yarik   Almost all databa...
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
          /**
           * @inheritdoc
           */
          public function up()
          {
              $this->createTable(
                  'stock_lang',
                  [
                      'stock_id'    => $this->integer()
                                            ->notNull(),
                      'language_id' => $this->integer()
                                            ->notNull(),
                      'title'       => $this->string()
                                            ->notNull(),
                  ]
              );
              $this->createIndex(
                  'stock_lang_stock_language_key',
                  'stock_lang',
                  [
                      'stock_id',
                      'language_id',
                  ],
                  true
              );
              
              $this->addForeignKey('stock_fk', 'stock_lang', 'stock_id', 'stock', 'id', 'CASCADE', 'CASCADE');
              $this->addForeignKey('language_fk', 'stock_lang', 'language_id', 'language', 'id', 'RESTRICT', 'CASCADE');
          }
e8ccb1b4   Yarik   Import beta
39
          
4428da8c   Yarik   Almost all databa...
40
41
42
43
44
45
46
          /**
           * @inheritdoc
           */
          public function down()
          {
              $this->dropTable('stock_lang');
          }
e8ccb1b4   Yarik   Import beta
47
      }