Doctrine override_url error No such file or directory on Travis CI

Viewed 1484

I have the impression that this is a configuration problem with doctrine. Indeed my doctrine.yaml.

`doctrine:
dbal:
    dbname:               mydatabase
    host:                 localhost
    port:                 8889
    user:                 root
    password:             root
    driver:               pdo_mysql
    url:                  '%env(resolve:DATABASE_URL)%'
    unix_socket:          /Applications/MAMP/tmp/mysql/mysql.sock
    charset:              UTF8
    override_url:         true
    # IMPORTANT: You MUST configure your server version,
    # either here or in the DATABASE_URL env var (see .env file)
    #server_version: '13'
orm:
    auto_generate_proxy_classes: true
    naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
    auto_mapping: true
    mappings:
        App:
            is_bundle: false
            type: annotation
            dir: '%kernel.project_dir%/src/Entity'
            prefix: 'App\Entity'
            alias: App`

When I perform tests with the database it works but on Travis CI when I do this build

`language: php
php:
   - '7.3'
   services:
    - mysql
script:
    - composer install
    - php bin/console doctrine:database:create --env=test
    - php bin/console doctrine:schema:update --force --env=test
    - php bin/console doctrine:fixtures:load -n --env=test
    - php bin/phpunit`

travis when creating the database returns me:

    `php bin/console doctrine:database:create --env=test 382[critical] Error thrown       while running command "doctrine:database:create --env=test". Message: "An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory" 383 384 385In AbstractMySQLDriver.php line 112: 386 387 An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or dir`

And when I remove the override_url option in the conf doctrine the same build works on travis and not the tests with errors like

`Not setting doctrine.dbal.override_url to true is deprecated. True is the only value that will be supported in doctrine-bundle 3.0` or

      `Doctrine\DBAL\Driver\PDO\Exception: SQLSTATE[HY000] [2002] Connection refused`

I have not found a real solution and I have the impression that my config for my database is good. Maybe I need to upgrade the doctrine-bundle to 3.0? If anyone has a lead, I take it. Thank you in advance

1 Answers

According to the PR which added this depreciation, with override_url set to true, environment specific configs can override the database name (among other parameters).

So check whether config/packages/test/doctrine.yaml overrides any of the DATABASE_URL's parameters

Related