<?php

class m131125_130902_some_stuff extends MyDbMigration
{
	public function up()
	{
		try {
		
			$this->createIndex('vehicletable', 'index_list_code_id', 'list_code, ID');
		
		} catch (Exception $e) {
		}
		
		if ($this->dbConnection->schema->getTable('gate_behavior')->getColumn('transfer_empty_plates') == null)
			$this->addColumn('gate_behavior', 'transfer_empty_plates', 'boolean  DEFAULT 0');
		
		if ($this->dbConnection->schema->getTable('plate_list')->getColumn('downloadable') == null)
			$this->addColumn('plate_list', 'downloadable', 'boolean  DEFAULT 0');
	}

	public function down()
	{
		$this->dropIndex('index_list_code_id', 'vehicletable');

		if ($this->dbConnection->schema->getTable('gate_behavior')->getColumn('transfer_empty_plates') != null)
			$this->dropColumn('gate_behavior', 'transfer_empty_plates');
		
		if ($this->dbConnection->schema->getTable('plate_list')->getColumn('downloadable') != null)
			$this->dropColumn('plate_list', 'downloadable');
		
		return true;
	}

	/*
	// Use safeUp/safeDown to do migration with transaction
	public function safeUp()
	{
	}

	public function safeDown()
	{
	}
	*/
}