<?php

class m130903_073014_add_user_password_expiration extends MyDbMigration
{
	public function up()
	{
		if ($this->dbConnection->schema->getTable('users')->getColumn('password_timeout') == null)
			$this->addColumn('users', 'password_timeout', 'int');
			
		if ($this->dbConnection->schema->getTable('users')->getColumn('password_last_update') == null)
			$this->addColumn('users', 'password_last_update', 'datetime');
			
		if ($this->dbConnection->schema->getTable('users')->getColumn('can_change_password') == null)
			$this->addColumn('users', 'can_change_password', 'boolean');
	}

	public function down()
	{
		if ($this->dbConnection->schema->getTable('users')->getColumn('password_timeout') != null)
			$this->dropColumn('users', 'password_timeout');
			
		if ($this->dbConnection->schema->getTable('users')->getColumn('password_last_update') != null)
			$this->dropColumn('users', 'password_last_update');
			
		if ($this->dbConnection->schema->getTable('users')->getColumn('can_change_password') != null)
			$this->dropColumn('users', 'can_change_password'); 
		return true; 
	}

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

	public function safeDown()
	{
	}
	*/
}