2

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.

Thanks

  • Are you trying to make DB structure changes in upgrade script? – Roman Snitko May 4 '17 at 15:33
0

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);
    $cacheManager->clean([\Magento\Framework\DB\Adapter\DdlCache::TYPE_IDENTIFIER]);
    $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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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