<?php

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

class m151019_061146_add__table__money__movement 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('{{%money_movement}}', [
    			'id_money_movement' => $this->primaryKey(),
    			'id_account' => $this->integer()->notNull(),
    			'id_user' => $this->integer()->notNull(),
    			'name' => $this->string(64)->notNull(),
    			'type' => $this->integer()->notNull(),
    			'money' => $this->integer()->notNull(),
    			'comment' => $this->string(255),
    			'created_at' => $this->dateTime()->notNull(),
    			'updated_at' =>  $this->dateTime()->notNull(),
    	], $tableOptions);
    }

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

        return false;
    }

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

    public function safeDown()
    {
    }
    */
}
