<?php

class m130812_092557_add_latitude_longitude_to_gates extends MyDbMigration
{
	public function up()
	{
		if ($this->dbConnection->schema->getTable('gatetable')->getColumn('latitude') == null)
			$this->addColumn('gatetable', 'latitude', 'string');

		if ($this->dbConnection->schema->getTable('gatetable')->getColumn('longitude') == null)
			$this->addColumn('gatetable', 'longitude', 'string');

		if ($this->dbConnection->schema->getTable('gatetable')->getColumn('altitude') == null)
			$this->addColumn('gatetable', 'altitude', 'string');		
		
		
		if ($this->dbConnection->schema->getTable('gate_group')->getColumn('latitude') == null)
			$this->addColumn('gate_group', 'latitude', 'string');
		
		if ($this->dbConnection->schema->getTable('gate_group')->getColumn('longitude') == null)
			$this->addColumn('gate_group', 'longitude', 'string');
		
		if ($this->dbConnection->schema->getTable('gate_group')->getColumn('altitude') == null)
			$this->addColumn('gate_group', 'altitude', 'string');
		
	}

	public function down()
	{
		if ($this->dbConnection->schema->getTable('gatetable')->getColumn('latitude') != null)
			$this->dropColumn('gatetable', 'latitude');
		
		if ($this->dbConnection->schema->getTable('gatetable')->getColumn('longitude') != null)
			$this->dropColumn('gatetable', 'longitude');
		
		if ($this->dbConnection->schema->getTable('gatetable')->getColumn('altitude') != null)
			$this->dropColumn('gatetable', 'altitude');
		
		
		if ($this->dbConnection->schema->getTable('gate_group')->getColumn('latitude') != null)
			$this->dropColumn('gate_group', 'latitude');
		
		if ($this->dbConnection->schema->getTable('gate_group')->getColumn('longitude') != null)
			$this->dropColumn('gate_group', 'longitude');
		
		if ($this->dbConnection->schema->getTable('gate_group')->getColumn('altitude') != null)
			$this->dropColumn('gate_group', 'altitude');
				
		return true;
	}

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

	public function safeDown()
	{
	}
	*/
}