Symfony + Doctrine on the command line using the wrong database

• Bill Hunt

So, one us pilots was trying to use Doctrine migrations to update a database on one of our servers. However, Doctrine was sternly refusing to use the correct database, as configured in the database.yml file. As it turns out, using Symfony from the command line skips the usual route through the /web/yourapplication.php file (e.g. backend.php or frontend.php). As a result, the environment is not properly set when reading the database <a href="">team management app</a>.yml file, and instead the last database connection specified is used. Lame. The trick is to specify the environment from the command line, so this file (and the other config files) do what they’re supposed to:

<br /> symfony doctrine:migrate --env=staging frontend 119<br />

where “staging” is whatever the environment is you want to use (to match the name in the database.yml file).