diff --git a/composer.json b/composer.json index 3dca98f..38bacb6 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ }, "require": { "php": "^7.4 || ^8.0", - "doctrine/orm": "^2.3" + "doctrine/orm": "^2.10", + "doctrine/dbal": "^3.1.2" }, "require-dev": { "phpunit/phpunit": "^7.5", diff --git a/src/LiquibaseDOMDocumentOutput.php b/src/LiquibaseDOMDocumentOutput.php index f7b602c..3a596d6 100644 --- a/src/LiquibaseDOMDocumentOutput.php +++ b/src/LiquibaseDOMDocumentOutput.php @@ -4,7 +4,7 @@ namespace Fabiang\Doctrine\Migrations\Liquibase; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception as DBALException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; @@ -13,14 +13,13 @@ use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; -use Doctrine\DBAL\Platforms\MySqlPlatform; +use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\ORM\EntityManagerInterface; use DOMDocument; use DOMElement; class LiquibaseDOMDocumentOutput implements LiquibaseOutput { - private DOMDocument $document; private LiquibaseOutputOptions $options; private AbstractPlatform $platform; @@ -47,7 +46,7 @@ public function __construct(?LiquibaseOutputOptions $options = null, ?DOMDocumen } $this->root = $this->document->createElement('databaseChangeLog'); - $this->platform = new MySqlPlatform(); + $this->platform = new MySQLPlatform(); } public function getDocument(): DOMDocument @@ -71,7 +70,11 @@ protected function createChangeSet(string $id): DOMElement $changeSet->setAttribute('author', $this->options->getChangeSetAuthor()); $sanitizedId = preg_replace('/[_\.]/', '-', $id); assert($sanitizedId !== null); - $changeSet->setAttribute('id', $this->options->isChangeSetUniqueId() ? $sanitizedId . '-' . uniqid() : $sanitizedId); + $changeSet->setAttribute( + 'id', + $this->options->isChangeSetUniqueId() + ? $sanitizedId . '-' . uniqid() : $sanitizedId + ); $this->root->appendChild($changeSet); return $changeSet; } @@ -98,7 +101,9 @@ public function createSchema(string $newNamespace): void public function dropForeignKey(ForeignKeyConstraint $orphanedForeignKey, Table $localTable): void { - $changeSetElt = $this->createChangeSet('drop-foreign-key-' . $orphanedForeignKey->getName()); + $changeSetElt = $this->createChangeSet( + 'drop-foreign-key-' . $orphanedForeignKey->getName() + ); $tableName = QualifiedName::fromAsset($localTable); $foreignKeyName = QualifiedName::fromAsset($orphanedForeignKey); @@ -119,7 +124,9 @@ public function dropForeignKey(ForeignKeyConstraint $orphanedForeignKey, Table $ public function alterSequence(Sequence $sequence): void { - $commentElt = $this->document->createComment(' alterSequence is not supported (sequence: ' . $sequence->getName() . ')'); + $commentElt = $this->document->createComment( + ' alterSequence is not supported (sequence: ' . $sequence->getName() . ')' + ); $this->root->appendChild($commentElt); } diff --git a/tests/units/src/LiquibaseSchemaToolTest.php b/tests/units/src/LiquibaseSchemaToolTest.php index d2f676c..25d6883 100644 --- a/tests/units/src/LiquibaseSchemaToolTest.php +++ b/tests/units/src/LiquibaseSchemaToolTest.php @@ -61,6 +61,8 @@ protected function setUp(): void ->willReturn($this->platform->reveal()); $this->connection->getSchemaManager() ->willReturn($this->schemaManager->reveal()); + $this->connection->createSchemaManager() + ->willReturn($this->schemaManager->reveal()); $this->em = $this->prophesize(EntityManagerInterface::class); $this->em->getConnection()->willReturn($this->connection->reveal());