-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
139824d
commit 2aacd19
Showing
4 changed files
with
56 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ jobs: | |
run: php bin/console lint:yaml config src | ||
- name: doctrine:schema:validate | ||
if: always() | ||
run: php bin/console doctrine:schema:update --dump-sql | ||
run: php bin/console doctrine:schema:validate | ||
env: | ||
DATABASE_URL: mysql://root:[email protected]:${{ job.services.mysql.ports['3306'] }}/symfony | ||
- name: Archive logs as artifacts | ||
|
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
48 changes: 48 additions & 0 deletions
48
src/Core/Infrastructure/Doctrine/FixDoctrineMigrationTableSchema.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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Core\Infrastructure\Doctrine; | ||
|
||
use Doctrine\DBAL\Exception; | ||
use Doctrine\DBAL\Schema\SchemaException; | ||
use Doctrine\Migrations\DependencyFactory; | ||
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration; | ||
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; | ||
use Webmozart\Assert\Assert; | ||
|
||
/** @see https://github.com/doctrine/migrations/issues/1406 */ | ||
final class FixDoctrineMigrationTableSchema | ||
{ | ||
private TableMetadataStorageConfiguration $configuration; | ||
|
||
public function __construct( | ||
private readonly DependencyFactory $dependencyFactory, | ||
) { | ||
$configuration = $this->dependencyFactory->getConfiguration()->getMetadataStorageConfiguration(); | ||
|
||
Assert::notNull($configuration); | ||
Assert::isInstanceOf($configuration, TableMetadataStorageConfiguration::class); | ||
|
||
$this->configuration = $configuration; | ||
} | ||
|
||
/** | ||
* @throws SchemaException | ||
* @throws Exception | ||
*/ | ||
public function postGenerateSchema(GenerateSchemaEventArgs $args): void | ||
{ | ||
$schema = $args->getSchema(); | ||
$table = $schema->createTable($this->configuration->getTableName()); | ||
$table->addColumn( | ||
$this->configuration->getVersionColumnName(), | ||
'string', | ||
['notnull' => true, 'length' => $this->configuration->getVersionColumnLength()], | ||
); | ||
$table->addColumn($this->configuration->getExecutedAtColumnName(), 'datetime', ['notnull' => false]); | ||
$table->addColumn($this->configuration->getExecutionTimeColumnName(), 'integer', ['notnull' => false]); | ||
|
||
$table->setPrimaryKey([$this->configuration->getVersionColumnName()]); | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
src/Core/Infrastructure/Doctrine/PostGenerateSchemaListener.php
This file was deleted.
Oops, something went wrong.