-
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1167 from shadowhand/fix/1166-all-or-nothing-asse…
…rtion Check for all-or-nothing conflict in migrations
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
lib/Doctrine/Migrations/Exception/MigrationConfigurationConflict.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Migrations\Exception; | ||
|
||
use Doctrine\Migrations\AbstractMigration; | ||
use UnexpectedValueException; | ||
|
||
use function get_class; | ||
use function sprintf; | ||
|
||
final class MigrationConfigurationConflict extends UnexpectedValueException implements MigrationException | ||
{ | ||
public static function migrationIsNotTransactional(AbstractMigration $migration): self | ||
{ | ||
return new self(sprintf( | ||
<<<'EXCEPTION' | ||
Context: attempting to execute migrations with all-or-nothing enabled | ||
Problem: migration %s is marked as non-transactional | ||
Solution: disable all-or-nothing in configuration or by command-line option, or enable transactions for all migrations | ||
EXCEPTION | ||
, | ||
get_class($migration) | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/Doctrine/Migrations/Tests/Stub/NonTransactional/MigrationNonTransactional.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Migrations\Tests\Stub\NonTransactional; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
class MigrationNonTransactional extends AbstractMigration | ||
{ | ||
public function up(Schema $schema): void | ||
{ | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
} | ||
|
||
public function isTransactional(): bool | ||
{ | ||
return false; | ||
} | ||
} |