<?php

class m140901_164600_add_contactinfo_to_usertable extends MyDbMigration
{
  public function up()
  {
    if ($this->dbConnection->schema->getTable('usertable')->getColumn('email') == null)
      $this->addColumn('usertable', 'email', 'string');
    if ($this->dbConnection->schema->getTable('usertable')->getColumn('address') == null)
      $this->addColumn('usertable', 'address', 'string');
    if ($this->dbConnection->schema->getTable('usertable')->getColumn('city') == null)
      $this->addColumn('usertable', 'city', 'string');
    if ($this->dbConnection->schema->getTable('usertable')->getColumn('phone') == null)
      $this->addColumn('usertable', 'phone', 'string');
  }

  public function down()
  {
    if ($this->dbConnection->schema->getTable('usertable')->getColumn('phone') != null)
      $this->dropColumn('usertable', 'phone');
    if ($this->dbConnection->schema->getTable('usertable')->getColumn('city') != null)
      $this->dropColumn('usertable', 'city');
    if ($this->dbConnection->schema->getTable('usertable')->getColumn('address') != null)
      $this->dropColumn('usertable', 'address');
    if ($this->dbConnection->schema->getTable('usertable')->getColumn('email') != null)
      $this->dropColumn('usertable', 'email');
    
    return true;
  }
}