phpdoctrinedoctrine-migrations

No table with name "doctrine_migration_versions" in the schema


I have an application that uses Doctrine to manage its migrations. This has worked well during development, but when trying to deploy the application on a fresh database, the migration command fails.

I can run the database creation command successfully:

php bin/console doctrine:database:create --if-not-exists

This connects to the database and can both create the database, or check that it exists and skip. So this is not a connection issue, etc.

The next command, however, fails:

php bin/console doctrine:migrations:migrate

It throws the error on the title of this question:

In TableDoesNotExist.php line 16:
                                                                            
  [Doctrine\DBAL\Schema\Exception\TableDoesNotExist (10)]                   
  There is no table with name "doctrine_migration_versions" in the schema. 

I'm pretty new to Doctrine in general, so it's unclear to me what this error is even complaining about. How can I fix it? Is this a configuration problem on the fresh environment?


Solution

  • This turned out to be a permissions issue. I couldn't find in the Doctrine docs any mention of which permissions the DB user required, but granting all privileges on the configured database sorted out the issue:

    GRANT ALL PRIVILEGES ON my_database.* TO 'my_user'@'%';