<?php

use yii\db\Schema;
use yii\db\Migration;

class m170103_175608_alter__product__add__column__purchase_net_price extends Migration
{
    public function up()
    {
        $this->addColumn("product", "purchase_net_price", "int default 0");
        $this->execute("update product set purchase_net_price = purchase_price -  FLOOR( purchase_price * tax / 100 )");
    }

    public function down()
    {
        echo "m170103_175608_alter__product__add__column__purchase_net_price cannot be reverted.\n";

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
