From bcb1cd71e8c97ddddb5737915a9c8232ef81f190 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Sun, 7 Feb 2021 20:33:47 -0600 Subject: [PATCH 1/2] add current known foriegn key fixes possibly required post upgrading --- doc/Update.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/Update.md b/doc/Update.md index c4fe16186..db986126c 100644 --- a/doc/Update.md +++ b/doc/Update.md @@ -77,3 +77,32 @@ RENAME TABLE _new TO ; ``` This method is slower overall, but it is better suited for large numbers of duplicates. + +### Resolving Possible Database Issues Post Upgrading + +#### Foriegn Keys + +Some of the updates include the use of foreign keys now that will bump +into issues with previous versions, which would sometimes shove bad +data into tables, preventing, causing errors such as below. + +``` +Error 1452 occurred during database update: +Cannot add or update a child row: a foreign key constraint fails (`friendica`.`#sql-10ea6_5a6d`, CONSTRAINT `#sql-10ea6_5a6d_ibfk_1` FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`)) +ALTER TABLE `thread` ADD FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE; +``` + +All current known fixes for possible items that can go wrong are as below. + +```SQL +delete from item where `owner-id` not in (select id from contact); +delete from item where `contact-id` not in (select id from contact); +delete from notify where `uri-id` not in (select id from `item-uri`); +delete from photo where `contact-id` not in (select id from contact); +delete from thread where iid not in (select id from item); +delete from item where `author-id` not in (select id from contact); +delete from diaspora-interaction where uri-id not in (select id from item-uri); +``` + +This all has been compiled as of currently from issue #9746, #9753, +and #9878. From 48ebb4b731fc4fcc05eae62c3855a4f37f296515 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 7 Feb 2021 22:00:47 -0500 Subject: [PATCH 2/2] Improve formatting in doc/Update.md - Fix typo - Enforce Markdown convention of a sentence per line - Improve SQL formatting regarding language keywords and escaped identifiers --- doc/Update.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/doc/Update.md b/doc/Update.md index db986126c..d019d03b0 100644 --- a/doc/Update.md +++ b/doc/Update.md @@ -80,11 +80,9 @@ This method is slower overall, but it is better suited for large numbers of dupl ### Resolving Possible Database Issues Post Upgrading -#### Foriegn Keys +#### Foreign Keys -Some of the updates include the use of foreign keys now that will bump -into issues with previous versions, which would sometimes shove bad -data into tables, preventing, causing errors such as below. +Some of the updates include the use of foreign keys now that will bump into issues with previous versions, which would sometimes shove bad data into tables, preventing, causing errors such as below. ``` Error 1452 occurred during database update: @@ -95,14 +93,13 @@ ALTER TABLE `thread` ADD FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE All current known fixes for possible items that can go wrong are as below. ```SQL -delete from item where `owner-id` not in (select id from contact); -delete from item where `contact-id` not in (select id from contact); -delete from notify where `uri-id` not in (select id from `item-uri`); -delete from photo where `contact-id` not in (select id from contact); -delete from thread where iid not in (select id from item); -delete from item where `author-id` not in (select id from contact); -delete from diaspora-interaction where uri-id not in (select id from item-uri); +DELETE FROM `item` WHERE `owner-id` NOT IN (SELECT `id` FROM `contact`); +DELETE FROM `item` WHERE `contact-id` NOT IN (SELECT `id` FROM `contact`); +DELETE FROM `notify` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`); +DELETE FROM `photo` WHERE `contact-id` NOT IN (SELECT `id` FROM `contact`); +DELETE FROM `thread` WHERE `iid` NOT IN (SELECT `id` FROM `item`); +DELETE FROM `item` WHERE `author-id` NOT IN (SELECT `id` FROM `contact`); +DELETE FROM `diaspora-interaction` WHERE `uri-id` NOT IN (SELECT `id` FROM `item-uri`); ``` -This all has been compiled as of currently from issue #9746, #9753, -and #9878. +This all has been compiled as of currently from issue #9746, #9753, and #9878.