Search code examples
symfonycachingdoctrinecapifony

Should I clear/warm cache after doctrine migrations?


I would like to know about how symfony2 console commands cache:clear and cache:warmup works in regards to changes in doctrine entities.

I've read this http://blog.whiteoctober.co.uk/2014/02/25/symfony2-cache-warmup-explained/ and this https://stackoverflow.com/a/17787070/779320. There it is stated that symfony2 warm-up generates Doctrine proxies.

Thing is, I frequently have a situation after application deploy using capifony where I must run doctrine migrations. After that I always run cache:clear and cache:warmup.

According to the links above (if I understand correctly), if there is any entity addition/deletion, I should run cache:warmup. But what if there is only entity's fields changes. Should I run both cache:clear and cache:warmup commands necessary to be run or just one? Or, which one is necessary? Or, not at all?


Solution

  • Migrations are responsible for persistence layer only. It has nothing to do with EntityProxies, it only makes Database in sync with Model - that's all.

    In production, during deployment, you probably run git pull and composer install, which clears the cache, so migrations shoud run just after that.

    Reason - after composer install your new code and Model itself is ready to use new fields/entities, but the Database still falls behind, so migrations keeps it in sync.