Tips

MongoDB indexes

Sometimes updating the indexes using Doctrine schema update for MongoDB Indexes can give some problems. This can be very annoying, but fortunately there is a fix.

1
2
3
4
5
6
7
account@042:~$ php bin/console doctrine:mongodb:schema:update
Updated indexes for all classes
account@042:~$ php bin/console doctrine:mongodb:schema:create 
Created dbs for all classes
Created collections for all classes
Created indexes for all classes
account@042:~$

If you run the following command in a production environment, it is wise to test on a test environment first. If you have production traffic, the database queries may delay until the indexes have been removed. In other cases you can run the following command safely, it won't purge the database. Using this command will result in a fast application (again).