Skip to content

vt8.2 Foreign Key Constraint failing on MariaDB 11

We are running 8.2.0 on a server with MariaDB 11. During the database creation the table vtiger_webforms_field has not been created (but did not throw any errors) After creating a webform on the CRM, then attempting to edit, we encountered an error, and traced it back to this table not existing.

We tried running the SQL query (from /modules/WebForms/schema.xml) to recreate the table and get: Can't create table dev_crm.vtiger_webforms_field (errno: 150 "Foreign key constraint is incorrectly formed")

Yet on older versions of MariaDB this query has run successfully as the table correctly exists.

The error appears to be due to the fact that the create table statement: CREATE TABLE vtiger_webforms_field(idint(19) NOT NULL AUTO_INCREMENT,webformidint(19) NOT NULL,fieldnamevarchar(50) NOT NULL,neutralizedfieldvarchar(50) NOT NULL,defaultvalueTEXT DEFAULT NULL,requiredint(10) NOT NULL DEFAULT '0',sequenceint(10) DEFAULT NULL,hidden int(10) DEFAULT NULL, PRIMARY KEY (id), KEY webforms_webforms_field_idx (id), KEY fk_1_vtiger_webforms_field (webformid), KEY fk_2_vtiger_webforms_field (fieldname), CONSTRAINT fk_1_vtiger_webforms_field FOREIGN KEY (webformid) REFERENCES vtiger_webforms (id) ON DELETE CASCADE, CONSTRAINT fk_3_vtiger_webforms_field FOREIGN KEY (fieldname) REFERENCES vtiger_field (fieldname) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8

references the field vtiger_field.fieldname and this column is not UNIQUE.

Really would be a good idea to be able to run the DB on latest version of MariaDB 😄 (would also be good idea if rather than using the fieldname as a foreign key it used the fieldid !)