diff -r bbdc7f9aa25e -r 03b14b0fe101 vendor/doctrine-migrations/lib/Doctrine/DBAL/Migrations/AbstractMigration.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/doctrine-migrations/lib/Doctrine/DBAL/Migrations/AbstractMigration.php Fri Nov 25 18:55:43 2011 +0100 @@ -0,0 +1,178 @@ +. +*/ + +namespace Doctrine\DBAL\Migrations; + +use Doctrine\DBAL\Schema\Schema, + Doctrine\DBAL\Migrations\Configuration\Configuration, + Doctrine\DBAL\Migrations\Version; + +/** + * Abstract class for individual migrations to extend from. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Jonathan H. Wage + */ +abstract class AbstractMigration +{ + /** + * The Migrations Configuration instance for this migration + * + * @var Configuration + */ + private $configuration; + + /** + * The OutputWriter object instance used for outputting information + * + * @var OutputWriter + */ + private $outputWriter; + + /** + * The Doctrine\DBAL\Connection instance we are migrating + * + * @var Connection + */ + protected $connection; + + /** + * Reference to the SchemaManager instance referened by $_connection + * + * @var \Doctrine\DBAL\Schema\AbstractSchemaManager + */ + protected $sm; + + /** + * Reference to the DatabasePlatform instance referenced by $_conection + * + * @var \Doctrine\DBAL\Platforms\AbstractPlatform + */ + protected $platform; + + /** + * Reference to the Version instance representing this migration + * + * @var Version + */ + protected $version; + + public function __construct(Version $version) + { + $this->configuration = $version->getConfiguration(); + $this->outputWriter = $this->configuration->getOutputWriter(); + $this->connection = $this->configuration->getConnection(); + $this->sm = $this->connection->getSchemaManager(); + $this->platform = $this->connection->getDatabasePlatform(); + $this->version = $version; + } + + /** + * Get custom migration name + * + * @return string + */ + public function getName() + { + } + + abstract public function up(Schema $schema); + abstract public function down(Schema $schema); + + protected function addSql($sql, array $params = array()) + { + return $this->version->addSql($sql, $params); + } + + protected function write($message) + { + $this->outputWriter->write($message); + } + + protected function throwIrreversibleMigrationException($message = null) + { + if ($message === null) { + $message = 'This migration is irreversible and cannot be reverted.'; + } + throw new IrreversibleMigrationException($message); + } + + /** + * Print a warning message if the condition evalutes to TRUE. + * + * @param bool $condition + * @param string $message + */ + public function warnIf($condition, $message = '') + { + $message = (strlen($message)) ? $message : 'Unknown Reason'; + + if ($condition === true) { + $this->outputWriter->write(' Warning during ' . $this->version->getExecutionState() . ': ' . $message . ''); + } + } + + /** + * Abort the migration if the condition evalutes to TRUE. + * + * @param bool $condition + * @param string $message + */ + public function abortIf($condition, $message = '') + { + $message = (strlen($message)) ? $message : 'Unknown Reason'; + + if ($condition === true) { + throw new AbortMigrationException($message); + } + } + + /** + * Skip this migration (but not the next ones) if condition evalutes to TRUE. + * + * @param bool $condition + * @param string $message + */ + public function skipIf($condition, $message = '') + { + $message = (strlen($message)) ? $message : 'Unknown Reason'; + + if ($condition === true) { + throw new SkipMigrationException($message); + } + } + + public function preUp(Schema $schema) + { + } + + public function postUp(Schema $schema) + { + } + + public function preDown(Schema $schema) + { + } + + public function postDown(Schema $schema) + { + } +}