Blame view

console/migrations/m161011_104931_create_stock_lang_table.php 1.04 KB
e8ccb1b4   Yarik   Import beta
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
  <?php
  
  use yii\db\Migration;
  
  /**
   * Handles the creation for table `stock_lang`.
   */
  class m161011_104931_create_stock_lang_table extends Migration
  {
      /**
       * @inheritdoc
       */
      public function up()
      {
          $this->createTable('stock_lang', [
              'stock_id' => $this->integer()
                                      ->notNull(),
              'language_id'  => $this->integer()
                                     ->notNull(),
              'name'         => $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', 'stock_id', 'CASCADE', 'CASCADE');
          $this->addForeignKey('language_fk', 'stock_lang', 'language_id', 'language', 'language_id', 'RESTRICT', 'CASCADE');
      }
  
      /**
       * @inheritdoc
       */
      public function down()
      {
          $this->dropTable('stock_lang');
      }
  }