Skip to content

Commit 2aacd19

Browse files
committed
fix ci
1 parent 139824d commit 2aacd19

File tree

4 files changed

+56
-39
lines changed

4 files changed

+56
-39
lines changed

.github/workflows/github-actions.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
run: php bin/console lint:yaml config src
7777
- name: doctrine:schema:validate
7878
if: always()
79-
run: php bin/console doctrine:schema:update --dump-sql
79+
run: php bin/console doctrine:schema:validate
8080
env:
8181
DATABASE_URL: mysql://root:[email protected]:${{ job.services.mysql.ports['3306'] }}/symfony
8282
- name: Archive logs as artifacts

config/services.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,10 @@ services:
5252
App\Core\Infrastructure\ElasticSearch\Helper\OfficialElasticSearchHelper:
5353
arguments:
5454
$elasticsearchHost: "%env(ELASTICSEARCH_IRI)%"
55+
56+
App\Core\Infrastructure\Doctrine\FixDoctrineMigrationTableSchema:
57+
autoconfigure: false
58+
arguments:
59+
$dependencyFactory: "@doctrine.migrations.dependency_factory"
60+
tags:
61+
- { name: "doctrine.event_listener", event: "postGenerateSchema" }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Core\Infrastructure\Doctrine;
6+
7+
use Doctrine\DBAL\Exception;
8+
use Doctrine\DBAL\Schema\SchemaException;
9+
use Doctrine\Migrations\DependencyFactory;
10+
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration;
11+
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
12+
use Webmozart\Assert\Assert;
13+
14+
/** @see https://github.com/doctrine/migrations/issues/1406 */
15+
final class FixDoctrineMigrationTableSchema
16+
{
17+
private TableMetadataStorageConfiguration $configuration;
18+
19+
public function __construct(
20+
private readonly DependencyFactory $dependencyFactory,
21+
) {
22+
$configuration = $this->dependencyFactory->getConfiguration()->getMetadataStorageConfiguration();
23+
24+
Assert::notNull($configuration);
25+
Assert::isInstanceOf($configuration, TableMetadataStorageConfiguration::class);
26+
27+
$this->configuration = $configuration;
28+
}
29+
30+
/**
31+
* @throws SchemaException
32+
* @throws Exception
33+
*/
34+
public function postGenerateSchema(GenerateSchemaEventArgs $args): void
35+
{
36+
$schema = $args->getSchema();
37+
$table = $schema->createTable($this->configuration->getTableName());
38+
$table->addColumn(
39+
$this->configuration->getVersionColumnName(),
40+
'string',
41+
['notnull' => true, 'length' => $this->configuration->getVersionColumnLength()],
42+
);
43+
$table->addColumn($this->configuration->getExecutedAtColumnName(), 'datetime', ['notnull' => false]);
44+
$table->addColumn($this->configuration->getExecutionTimeColumnName(), 'integer', ['notnull' => false]);
45+
46+
$table->setPrimaryKey([$this->configuration->getVersionColumnName()]);
47+
}
48+
}

src/Core/Infrastructure/Doctrine/PostGenerateSchemaListener.php

-38
This file was deleted.

0 commit comments

Comments
 (0)