Blame view

console/migrations/m160217_145813_add_fields_february.php 1.57 KB
14a09168   Alex Savenko   init 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
  <?php

  

      use yii\db\Migration;

  

      class m160217_145813_add_fields_february extends Migration

      {

  

          public function up()

          {

              /* Create vacancy_specialization table */

              $this->createTable('{{%vacancy_specialization}}', [

                  'vacancy_specialization_id' => $this->primaryKey(),

                  'vacancy_id'                => $this->integer(),

                  'specialization_id'         => $this->integer(),

              ]);

  

              /* Connect vacancy_specialization table with vacancy and specialization tables */

              $this->addForeignKey('vacancy_specialization_vacancy', '{{%vacancy_specialization}}', 'vacancy_id', '{{%vacancy}}', 'vacancy_id', 'CASCADE', 'CASCADE');

              $this->addForeignKey('vacancy_specialization_specialization', '{{%vacancy_specialization}}', 'specialization_id', '{{%specialization}}', 'specialization_id', 'CASCADE', 'CASCADE');

  

              /* Add phone column to vacancy */

              $this->addColumn('{{%vacancy}}', 'phone', $this->string());

              $this->addColumn('{{%vacancy}}', 'salary', $this->string());

          }

  

          public function down()

          {

              $this->dropForeignKey('vacancy_specialization_vacancy', '{{%vacancy_specialization}}');

              $this->dropForeignKey('vacancy_specialization_specialization', '{{%vacancy_specialization}}');

  

              $this->dropColumn('{{%vacancy}}', 'phone');

              $this->dropColumn('{{%vacancy}}', 'salary');

  

              $this->dropTable('{{%vacancy_specialization}}');

          }

  

      }