<?php

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

class m160316_063618_create__table__log extends Migration
{
    public function up()
    {
		/*
		 * log
id_log
type
message
url
app
id_user
id_transfer
id_money_movement
id_ticket
id_sale
id_customer
id_card
id_account
id_account_state
id_key
id_product
id_door_log
		 * */
    	
    	$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( '{{%log}}', [
    			'id_log' => $this->primaryKey(),
    			'type' => $this->integer(11),
    			'message' => $this->string(),
    			'url' => $this->text(),
    			'app' => $this->string(50),
    			'id_user' => $this->integer(11),
    			'id_transfer' => $this->integer(11),
    			'id_money_movement' => $this->integer(11),
    			'id_ticket' => $this->integer(11),
    			'id_sale' => $this->integer(11),
    			'id_customer' => $this->integer(11),
    			'id_account' => $this->integer(11),
    			'id_account_state' => $this->integer(11),
    			'id_key' => $this->integer(11),
    			'id_product' => $this->integer(11),
    			'id_door_log' => $this->integer(11),
    			'created_at' => $this->dateTime()->notNull(),
    			'updated_at' =>  $this->dateTime()->notNull(),
    	], $tableOptions );
		    	
    }

    public function down()
    {
      $this->dropTable("{{%log}}");
    }

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

    public function safeDown()
    {
    }
    */
}
