Skip to content

Commit

Permalink
Dump minimum version of DBAL to 3.1.2 due to namechanges and bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiang committed Nov 23, 2021
1 parent 4c8b089 commit 45c2579
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 14 additions & 7 deletions src/LiquibaseDOMDocumentOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/units/src/LiquibaseSchemaToolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 45c2579

Please sign in to comment.