Yeah, i know
Basically, some of your database tables are missing the foreign keys constraints.
The good news is we have them stored in a file so you can run the queries via phpmyadmin to add the missing constraints.
The file apps/common/data/install-sql/schema.sql contains all the queries mailwizz runs at install.
If you scroll down to line ~2273, you can see how the script starts adding contraints, i.e:
Code:
ALTER TABLE `article_category`
ADD CONSTRAINT `fk_article_category_article_category1` FOREIGN KEY (`parent_id`) REFERENCES `article_category` (`category_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
Of course, you have to add the table prefix, that is
mw_ so:
Code:
ALTER TABLE `mw_article_category`
ADD CONSTRAINT `fk_article_category_article_category1` FOREIGN KEY (`parent_id`) REFERENCES `mw_article_category` (`category_id`) ON DELETE CASCADE ON UPDATE NO ACTION;
Some tables, do have the constraints, for example, if we run:
Code:
show create table mw_article_category;
We can see:
Code:
| mw_article_category | CREATE TABLE `mw_article_category` (
`category_id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(11) DEFAULT NULL,
`name` varchar(200) NOT NULL,
`slug` varchar(250) NOT NULL,
`description` text,
`status` char(15) NOT NULL DEFAULT 'active',
`date_added` datetime NOT NULL,
`last_updated` datetime NOT NULL,
PRIMARY KEY (`category_id`),
UNIQUE KEY `slug` (`slug`),
KEY `fk_article_category_article_category1_idx` (`parent_id`),
CONSTRAINT `fk_article_category_article_category1` FOREIGN KEY (`parent_id`) REFERENCES `mw_article_category` (`category_id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
Which shows it has the constraints in it, so we can skip it and move to the next table, if the next table has the constraints, we can move to the next one, and so on.
Just follow the order of the queries as they are set in the above file. before running the query to add the constraint, check if the constraint exists and run the addition query only if it doesn't.
Now, you might also want to run this query:
Code:
DELETE FROM mw_list_field_value WHERE subscriber_id IN(
SELECT * FROM(
SELECT distinct(t.subscriber_id) AS subscriber_id from mw_list_field_value t left join mw_list_subscriber s on s.subscriber_id = t.subscriber_id WHERE s.subscriber_id IS NULL
) as t1
);
Which deletes the orphaned records from mw_list_field_value.
Please make sure you backup before going this road.