m151016_144435_addViewDetailsCurrency.php 672 Bytes
<?php

use yii\db\Schema;
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);

    }
}