#doctrine:
#    dbal:
#        url: '%env(resolve:DATABASE_URL)%'
#
#        # IMPORTANT: You MUST configure your server version,
#        # either here or in the DATABASE_URL env var (see .env file)
#        #server_version: '15'
doctrine:
    dbal:
        # Define the default connection name
        default_connection: default
        
        connections:
            # 1. PRIMARY CONNECTION (Used by the ORM and for default services)
            default:
                url: '%env(DATABASE_URL)%'
                # Make sure these match your local configuration if needed
#                server_version: '8.0.32'
#                charset: utf8mb4

            # 2. SECONDARY CONNECTION (DBAL Only - for remote fetching/inserting)
            secondary: 
                url: '%env(DATABASE_URL_SECONDARY)%'
                # Set options appropriate for a remote connection (e.g., higher timeout)
#                server_version: '8.0.32'
#                charset: utf8mb4
                # Example of adding a connection timeout for remote access (optional)
#                options:
#                    1002: { default_timeout: 10 } # SQLSTATE_READ_TIMEOUT
#        profiling_collect_backtrace: '%kernel.debug%'
        
    orm:
        dql:
            datetime_functions:
                DATE: DoctrineExtensions\Query\Mysql\Date
                DATE_FORMAT: DoctrineExtensions\Query\Mysql\DateFormat
                TIMESTAMPDIFF: DoctrineExtensions\Query\Mysql\TimestampDiff
            string_functions:
                MATCH_AGAINST: DoctrineExtensions\Query\Mysql\MatchAgainst   
                
        auto_generate_proxy_classes: true
        enable_lazy_ghost_objects: true
        report_fields_where_declared: true
        validate_xml_mapping: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        
        mappings:
            App:
                is_bundle: false
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App
            SonataUserBundle: # Assuming you have SonataUserBundle configured
                is_bundle: false
                type: xml
                dir: '%kernel.project_dir%/vendor/sonata-project/user-bundle/src/Resources/config/doctrine'
                prefix: 'Sonata\UserBundle\Entity'
                alias: SonataUserBundle
            VichUploaderBundle: # Assuming you have VichUploaderBundle configured
                is_bundle: false
                type: attribute # Or yaml/xml depending on how Vich entities are mapped
                dir: '%kernel.project_dir%/vendor/vich/uploader-bundle/src/Entity' # Adjust if Vich entities are in a different location
                prefix: 'Vich\UploaderBundle\Entity'
                alias: VichUploaderBundle
            Gedmo: # NEW: Add this mapping for Gedmo's internal entities
                is_bundle: false
                type: attribute # Gedmo's LogEntry uses attributes
                dir: '%kernel.project_dir%/vendor/gedmo/doctrine-extensions/src/Loggable/Entity'
                prefix: 'Gedmo\Loggable\Entity'
                alias: Gedmo
#        entity_managers:
#            default:
#                mappings:
#                    SonataUserBundle: ~
when@test:
    doctrine:
        dbal:
            # "TEST_TOKEN" is typically set by ParaTest
            dbname_suffix: '_test%env(default::TEST_TOKEN)%'

when@prod:
    doctrine:
        orm:
            auto_generate_proxy_classes: false
            proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
            query_cache_driver:
                type: pool
                pool: doctrine.system_cache_pool
            result_cache_driver:
                type: pool
                pool: doctrine.result_cache_pool

    framework:
        cache:
            pools:
                doctrine.result_cache_pool:
                    adapter: cache.app
                doctrine.system_cache_pool:
                    adapter: cache.system
