CakePHP: Delete Cached Models on Database Change
Last week, I had to back out a (quite big) patch from the to-be-published addons.mozilla.org trunk because while it worked on our developer instances, it behaved totally strange on the staging environment: When I saved a record using the newly added UI, the changes partly didn’t show up in the database.
So we went ahead and delayed the release of the patch until we figured out what the problem was.
After a little digging around the internet today I found a hint suggesting to flush CakePHP’s cached models/table descriptions from the app/tmp/cache/models directory every time a database change is applied — which fixed the problem we encountered.
So, fellow CakePHP users, keep that in mind next time you alter your DB, and your life will be happier :).
My CakePHP inventory app that I wrote for the OSL does db schema upgrades automatically and cleans out that cache dir after. Took me a little while to figure out why my app worked in dev mode but not production mode.
Ah. Maybe we should do that too: It could save us a lot of pain next time we don’t remember it
If only i had known this a month ago, then you saved me alot of time : (
I figured it out by the hard way.
[…] if you change your database (as configured in app/config/database.php) make sure to delete the files in app/tmp/cache/models (see here) […]