Search code examples
postgresqlsymfonydoctrine-orm

Doctrine database create command failing with Postgresql


When in Symfony I am trying to create the database via doctrine:database:create it throws the following exception:

[Doctrine\DBAL\Exception\ConnectionException]                                
 An exception occured in driver: SQLSTATE[08006] [7] FATAL:  database "tm_ootb" does not exist

Am I facing a bug or am I missing something in the configuration.

Here is my dbal config:

dbal:
    driver:   pdo_pgsql
    host:     "%database_host%"
    port:     "%database_port%"
    dbname:   "%database_name%"
    user:     "%database_user%"
    password: "%database_password%"
    charset:  UTF8

Solution

  • Turns out that it is a Postgresql's permissions situation. Depending on the user level that you have configured on your parameters you will face this situation.

    When connecting to Postgres with the postgres super user account that also owns the administrative data base called postgres, there is no problem at all because it issues the following command:

    psql -U postgres

    No problem because user and database exist, after that issues the 'createdb' command. But when using any other user that do not owns a data base or is not super user it throws the mention error. There should be a way to avoid such error with Doctrine.

    Hopes this was useful for someone else.