<?php

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

class m160229_064305_inventory_group extends Migration
{
    public function up()
    {
    	$tableOptions = null;
    	if ($this->db->driverName === 'mysql') {
    		// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
    		$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
    	}
    	
    	$this->createTable('{{%inventory_group}}', [
    			'id_inventory_group' => $this->primaryKey(),
    			'name' => $this->string(),
    			'id_product_category' => $this->integer(11),
    			'status' => $this->integer(11),
    			'created_at' => $this->dateTime()->notNull(),
    			'updated_at' =>  $this->dateTime()->notNull(),
    	], $tableOptions);
    	
    	
    	$this->addColumn("product", "id_inventory_group", "int default null");
    }

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

        return false;
    }

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

    public function safeDown()
    {
    }
    */
}
