I created an update script to create some new fields in the database for my custom model. When I am trying to save the model the new fields are not being saved. I thing Magento caches the DDL information of the table. Is there a way to flush only that cache instead of clearing all cache? I tried with $connection->resetDdlCache(); but it didn't work.


  • Are you trying to make DB structure changes in upgrade script? May 4, 2017 at 15:33

3 Answers 3


This is how Magento 2 clears its DDL cache during setup:upgrade process:

private function cleanDdlCache()
    /** @var \Magento\Framework\App\Cache\Manager $cacheManager */
    $cacheManager = $this->objectManagerProvider->get()->get(\Magento\Framework\App\Cache\Manager::class);
    $this->log->log('DDL cache cleared successfully');

You can use the same code (and may be a few modifications) to programmatically clear DDL cache OR

Use CLI to run magento cache:flush(or clean) db_ddl.

Reference: http://devdocs.magento.com/guides/v2.1/config-guide/cli/config-cli-subcommands-cache.html


Can you try to disable all of the caches and then reenable them?

P/s: I was able to get it fixed the last time by doing so.


I know it's a bit late to reply :) here is how I clean DDL cache for one table in Magento 1.9 using a custom script :


$resource = Mage::getSingleton('core/resource');
$tableName = $resource->getTableName('MODULE/MODEL');

$key = sprintf('%s_%s_%s', Varien_Db_Adapter_Pdo_Mysql::DDL_CACHE_PREFIX,$tableName, Varien_Db_Adapter_Pdo_Mysql::DDL_DESCRIBE);
$cache = Mage::app()->getCache();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.