diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 31320c0ad..a5126459e 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -19,9 +19,7 @@ doctrine: JSONB_CONTAINS: Scienta\DoctrineJsonFunctions\Query\AST\Functions\Postgresql\JsonbContains auto_generate_proxy_classes: true enable_lazy_ghost_objects: true - # This option needs to be set to 'false', otherwise PHP class inheritance will fail with - # a separate sequence number generator table in PostgreSQL for each child class - report_fields_where_declared: false + report_fields_where_declared: true validate_xml_mapping: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware auto_mapping: true diff --git a/src/Kernel.php b/src/Kernel.php index 2d0398083..05e84dd6f 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -4,7 +4,11 @@ namespace App; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; +use Doctrine\ORM\Mapping\ClassMetadata; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; @@ -27,4 +31,23 @@ protected function configureRoutes(RoutingConfigurator $routes): void $routes->import($projectDir.'/config/{routes}.php'); } } + + #[Override] + protected function build(ContainerBuilder $container): void + { + $container->addCompilerPass(new class() implements CompilerPassInterface { + public function process(ContainerBuilder $container): void + { + $container->getDefinition('doctrine.orm.default_configuration') + ->addMethodCall( + 'setIdentityGenerationPreferences', + [ + [ + PostgreSQLPlatform::class => ClassMetadata::GENERATOR_TYPE_SEQUENCE, + ], + ] + ); + } + }); + } }