Blame view

console/migrations/m151016_144435_addViewDetailsCurrency.php 653 Bytes
f02e1203   Mihail   add migration for...
1
2
  <?php
  
f02e1203   Mihail   add migration for...
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
  use yii\db\Migration;
  
  class m151016_144435_addViewDetailsCurrency extends Migration
  {
      public function up()
      {
  
          $view = <<< MySQL
          create view w_details_currency as
          select w_details.*, w_currency.name, w_currency.rate  from w_details
          inner join  w_importers on w_importers.id = w_details.import_id
          inner join w_currency on w_currency.id = w_importers.currency_id;
  MySQL;
  
          $this->execute($view);
  
      }
  
      public function down()
      {
          // вернем все как было
          $drop_view = 'drop view if exists w_details_currency';
  
          $this->execute($drop_view);
  
      }
  }