Whenever I try to create a new static block from the backend, I always get the notice

"Could not save block, sorry something went wrong".

Checking logs I found this exception of the violation of an integrity constraint

> main.CRITICAL: Exception message: SQLSTATE[23000]: Integrity
> constraint violation: 1452 Cannot add or update a child row: a foreign
> key constraint fails (`my_db`.`cms_block_store`, CONSTRAINT
> REFERENCES `cms_block_live` (`block_id`) ON DELETE CASCADE), query
> was: INSERT INTO `cms_block_store` (`block_id`,`store_id`) VALUES (?,
> ?)

I've tried to delete orphans without a block_id in both tables, but it seems a strange behaviour.

In another Magento version I have installed, the table cms_block_live is not present, there's only the table cms_block, which is present also in this version, which is 2.1.10. Should cms_block_live be present?

I found there is a similar Magento bug in this verison, that has been fixed in 2.2 and 2.3 versions, but before upgrading, I would like to know if there is anybody else experiencing this issue.

1 Answer 1


The table cms_block_live is a custom table that has likely been added by a custom module. If you say the table is not present, it means the module that created this table may have been uninstalled and has left some remnants..

Now to resolve your issue, you need to remove the foreign constraints that mentions this table.

See https://stackoverflow.com/questions/14122031/how-to-remove-constraints-from-my-mysql-table to remove the constraint

  • Hi herve. Actually I removed the constraint, and I can add a block. The thing is that it's a magento core table, and it's not a good practice to modify it. Moreover I tried to delete and add the correct constraint to cms_block table, but I get a constraint violation error too. How can I know it is safe to remove the constraint? If I delete it, I will have orphans around tables that can cause bugs difficult to find.
    – sissy
    Commented Sep 10, 2018 at 15:36
  • What makes you thinking that it is a core table? Can’t you accept the answer like most people do when a problem is resolved? Commented Sep 10, 2018 at 20:39
  • Because the table cms_block_store IS a core table that is present with vanilla Magento installations. So I cannot just delete a constraint from this table. So I will not accept this answer as this is not a proper solution as expected.
    – sissy
    Commented Sep 11, 2018 at 10:25

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.