mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Delete dangling MySQL records when updating
MySQL seems to reject queries involving arsse_folders.parent and arsse_subscription.folder, though they appear to be valid. More testing is required.
This commit is contained in:
parent
737dd9f6b8
commit
568e6e4660
2 changed files with 28 additions and 2 deletions
|
@ -15,8 +15,7 @@ Upgrading from 0.8.1 to 0.8.2
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
- The database schema has changed from rev5 to rev6; if upgrading the database
|
- The database schema has changed from rev5 to rev6; if upgrading the database
|
||||||
manually, apply the 5.sql file. MySQL databases may need manual
|
manually, apply the 5.sql file
|
||||||
intervention to ensure foreign key constraints are not violated
|
|
||||||
|
|
||||||
|
|
||||||
Upgrading from 0.7.1 to 0.8.0
|
Upgrading from 0.7.1 to 0.8.0
|
||||||
|
|
|
@ -8,6 +8,33 @@
|
||||||
alter table arsse_sessions default character set utf8mb4 collate utf8mb4_unicode_ci;
|
alter table arsse_sessions default character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||||
alter table arsse_sessions convert to character set utf8mb4 collate utf8mb4_unicode_ci;
|
alter table arsse_sessions convert to character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- Ensure referential integrity
|
||||||
|
delete from arsse_folders where
|
||||||
|
owner not in (select id from arsse_users) or
|
||||||
|
(parent is not null and parent not in (select id from arsse_folders));
|
||||||
|
delete from arsse_subscriptions where
|
||||||
|
owner not in (select id from arsse_users) or
|
||||||
|
feed not in (select id from arsse_feeds) or
|
||||||
|
(folder is not null and folder not in (select id from arsse_folders));
|
||||||
|
delete from arsse_articles where feed not in (select id from arsse_feeds);
|
||||||
|
delete from arsse_enclosures where article not in (select id from arsse_articles);
|
||||||
|
delete from arsse_marks where
|
||||||
|
article not in (select id from arsse_articles) or
|
||||||
|
subscription not in (select id from arsse_subscriptions);
|
||||||
|
delete from arsse_editions where article not in (select id from arsse_articles);
|
||||||
|
delete from arsse_categories where article not in (select id from arsse_articles);
|
||||||
|
delete from arsse_sessions where "user" not in (select id from arsse_users);
|
||||||
|
delete from arsse_labels where owner not in (select id from arsse_users);
|
||||||
|
delete from arsse_label_members where
|
||||||
|
label not in (select id from arsse_labels) or
|
||||||
|
article not in (select id from arsse_articles) or
|
||||||
|
subscription not in (select id from arsse_subscriptions);
|
||||||
|
delete from arsse_tags where owner not in (select id from arsse_users);
|
||||||
|
delete from arsse_tag_members where
|
||||||
|
tag not in (select id from arsse_tags) or
|
||||||
|
subscription not in (select id from arsse_subscriptions);
|
||||||
|
delete from arsse_tokens where "user" not in (select id from arsse_users);
|
||||||
|
|
||||||
-- Make integer foreign key referrers unsigned to match serial-type keys
|
-- Make integer foreign key referrers unsigned to match serial-type keys
|
||||||
alter table arsse_folders modify parent bigint unsigned;
|
alter table arsse_folders modify parent bigint unsigned;
|
||||||
alter table arsse_subscriptions modify feed bigint unsigned not null;
|
alter table arsse_subscriptions modify feed bigint unsigned not null;
|
||||||
|
|
Loading…
Reference in a new issue