Browse Source

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.
microsub
J. King 4 years ago
parent
commit
568e6e4660
  1. 3
      UPGRADING
  2. 27
      sql/MySQL/5.sql

3
UPGRADING

@ -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
manually, apply the 5.sql file. MySQL databases may need manual
intervention to ensure foreign key constraints are not violated
manually, apply the 5.sql file
Upgrading from 0.7.1 to 0.8.0

27
sql/MySQL/5.sql

@ -8,6 +8,33 @@
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;
-- 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
alter table arsse_folders modify parent bigint unsigned;
alter table arsse_subscriptions modify feed bigint unsigned not null;

Loading…
Cancel
Save