Skip to content

Commit

Permalink
Merge pull request #887 from VincentLanglet/exception
Browse files Browse the repository at this point in the history
Allow to throw Exception in Migrations
  • Loading branch information
alcaeus committed Dec 4, 2019
2 parents b5d7611 + 87d43d2 commit a398713
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/Doctrine/Migrations/AbstractMigration.php
Expand Up @@ -5,11 +5,13 @@
namespace Doctrine\Migrations;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\Exception\AbortMigration;
use Doctrine\Migrations\Exception\IrreversibleMigration;
use Doctrine\Migrations\Exception\MigrationException;
use Doctrine\Migrations\Exception\SkipMigration;
use Doctrine\Migrations\Version\Version;
use function sprintf;
Expand Down Expand Up @@ -100,24 +102,42 @@ public function skipIf(bool $condition, string $message = '') : void
}
}

/**
* @throws MigrationException|DBALException
*/
public function preUp(Schema $schema) : void
{
}

/**
* @throws MigrationException|DBALException
*/
public function postUp(Schema $schema) : void
{
}

/**
* @throws MigrationException|DBALException
*/
public function preDown(Schema $schema) : void
{
}

/**
* @throws MigrationException|DBALException
*/
public function postDown(Schema $schema) : void
{
}

/**
* @throws MigrationException|DBALException
*/
abstract public function up(Schema $schema) : void;

/**
* @throws MigrationException|DBALException
*/
abstract public function down(Schema $schema) : void;

/**
Expand All @@ -137,6 +157,9 @@ protected function write(string $message) : void
$this->outputWriter->write($message);
}

/**
* @throws IrreversibleMigration
*/
protected function throwIrreversibleMigrationException(?string $message = null) : void
{
if ($message === null) {
Expand Down

0 comments on commit a398713

Please sign in to comment.