Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
bailletced committed Dec 3, 2024
1 parent 139824d commit 2aacd19
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ services:
App\Core\Infrastructure\ElasticSearch\Helper\OfficialElasticSearchHelper:
arguments:
$elasticsearchHost: "%env(ELASTICSEARCH_IRI)%"

App\Core\Infrastructure\Doctrine\FixDoctrineMigrationTableSchema:
autoconfigure: false
arguments:
$dependencyFactory: "@doctrine.migrations.dependency_factory"
tags:
- { name: "doctrine.event_listener", event: "postGenerateSchema" }
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 src/Core/Infrastructure/Doctrine/PostGenerateSchemaListener.php

This file was deleted.

0 comments on commit 2aacd19

Please sign in to comment.