I have an empty table amasty_audit_log_details
with the following constraint:
(The table in the screenshot is "amasty_audit_log_entry")
I also tried to change "On Update" and "On Delete" to NO UPDATE
but I get the same error.
Error:
SQLSTATE[23000]: Integrity constraint violation:
1452 Cannot add or update a child row: a foreign key constraint fails
`xxxxxxx_28072022`.`amasty_audit_log_details`,
CONSTRAINT `AMASTY_AUDIT_LOG_DETAILS_LOG_ID_AMASTY_AUDIT_LOG_ENTRY_ID`
FOREIGN KEY (`log_id`)
REFERENCES `amasty_audit_log_entry`
query was:
INSERT INTO `amasty_audit_log_details` (`log_id`, `name`, `old_value`, `new_value`, `model`) VALUES (?, ?, ?, ?, ?)
The table amasty_audit_log_entry
is also empty.
What might be the cause?
More Details:
amasty_audit_log_details:
CREATE TABLE IF NOT EXISTS `amasty_audit_log_details` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log Detail ID',
`log_id` int(10) unsigned NOT NULL COMMENT 'Log Entry ID',
`name` text DEFAULT NULL COMMENT 'Name',
`old_value` text DEFAULT NULL COMMENT 'Old Value',
`new_value` text DEFAULT NULL COMMENT 'New Value',
`model` text DEFAULT NULL COMMENT 'Model',
PRIMARY KEY (`id`),
KEY `idx_amasty_amaudit_details_log_id` (`log_id`),
KEY `AMASTY_AUDIT_LOG_DETAILS_LOG_ID` (`log_id`),
CONSTRAINT `AMASTY_AUDIT_LOG_DETAILS_LOG_ID_AMASTY_AUDIT_LOG_ENTRY_ID` FOREIGN KEY (`log_id`) REFERENCES `amasty_audit_log_entry` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COMMENT='Amasty Admin Actions Log Log Detail Table';
amasty_audit_log_entry:
CREATE TABLE IF NOT EXISTS `amasty_audit_log_entry` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Log Entry ID',
`date` datetime DEFAULT NULL COMMENT 'Log Entry Date',
`username` varchar(40) DEFAULT NULL COMMENT 'Log Entry Username',
`type` varchar(70) DEFAULT NULL COMMENT 'Log Entry Type',
`category` varchar(255) DEFAULT NULL COMMENT 'Log Entry Category',
`category_name` varchar(255) DEFAULT NULL COMMENT 'Log Entry Category Name',
`parameter_name` varchar(255) DEFAULT NULL COMMENT 'Log Entry Parameter Name',
`element_id` int(10) unsigned NOT NULL COMMENT 'Log Entry Element ID',
`item` text DEFAULT NULL COMMENT 'Log Entry Item',
`ip` varchar(30) DEFAULT NULL COMMENT 'Log Entry Item',
`store_id` int(10) unsigned DEFAULT NULL COMMENT 'Log Entry Store ID',
`additional_data` blob DEFAULT NULL COMMENT 'Additional serialized data',
PRIMARY KEY (`id`),
KEY `AMASTY_AUDIT_LOG_ENTRY_USERNAME` (`username`),
KEY `AMASTY_AUDIT_LOG_ENTRY_CATEGORY` (`category`),
KEY `AMASTY_AUDIT_LOG_ENTRY_ELEMENT_ID` (`element_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Amasty Admin Actions Log Entry Table';