Blame view

console/migrations/m160217_145813_add_fields_february.php 1.54 KB
af52e881   Yarik   test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  <?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());
1b56164e   Yarik   test
23
              $this->addColumn('{{%vacancy}}', 'salary', $this->string());
af52e881   Yarik   test
24
25
26
27
28
29
30
31
          }
  
          public function down()
          {
              $this->dropForeignKey('vacancy_specialization_vacancy', '{{%vacancy_specialization}}');
              $this->dropForeignKey('vacancy_specialization_specialization', '{{%vacancy_specialization}}');
  
              $this->dropColumn('{{%vacancy}}', 'phone');
1b56164e   Yarik   test
32
              $this->dropColumn('{{%vacancy}}', 'salary');
af52e881   Yarik   test
33
34
35
36
37
  
              $this->dropTable('{{%vacancy_specialization}}');
          }
  
      }