<?php

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

class m150921_162327_add__table__ticket_type 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('{{%ticket_type}}', [
    			'id_ticket_type' => $this->primaryKey(),
    			'name' => $this->string(64)->notNull(),
    			'type' => $this->integer(),
    			'max_usage_count' => $this->integer(),
    			'time_unit_type' => $this->integer(),
    			'time_unit_count' => $this->integer(),
    			'price_brutto' => $this->integer(),
    			'id_account' => $this->integer()->notNull(),
    			'flag_student' => $this->smallInteger()->notNull()->defaultValue(0),
    			'status' => $this->smallInteger()->notNull()->defaultValue(10),
    			'created_at' => $this->timestamp()->notNull(),
    			'updated_at' =>  $this->timestamp()->notNull(),
    	], $tableOptions );
    }

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

        return false;
    }

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

    public function safeDown()
    {
    }
    */
}
