Reputation: 193
When I give the following command:
php bin/console doctrine:schema:update --force
the database gets updated, but afterwards this command:
php bin/console doctrine:schema:validate
keeps saying that the database is not in sync (see below screenshot).
What am I missing/doing wrong?
Upvotes: 3
Views: 11452
Reputation: 10253
Depending on the database type and OS, the test may give some "false negatives", which means that your db is already ok but Doctrine doesn't quite understand. It happened to me in several projects, regardless of Symfony version (which means, Symfony 2,3 and 4).
Besides, in Symfony 4 you can use migrations as explained in the docs, that is:
bin/console make:migration
this command will create a migration file inside src/Migrations
, but won't touch the db.
To understand what's going on (from Doctrine's oint of view) you may have a look at the migration file: it's a PHP class with two methods (up()
and down()
).
The up()
method will contain the query/queries needed to align the database with your mapping files.
To apply all the pending migrations, run:
bin/console doctrine:migrations:migrate
Upvotes: 2