Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

error: Record is referenced by model

I would like delete records but I get error message

Record is referenced by model XXXXXXX

this model is belongTo other models but I can't delete related records because beforeDelete not trigger. Function _checkForeignKeysRestrict is execute before beforeDelete and breaking deletion process.

How can solve it?

                "foreignKey" => [
                    "action" => Relation::ACTION_CASCADE,

Thanks for tips. I had an option set "foreignKey" => true. After remove working properly.