-- Create a new label-associations table which omits the subscription column and populate it with new data
createtablearsse_label_members_new(
-- label assignments for articles
labelintegernotnullreferencesarsse_labels(id)ondeletecascade,-- label ID associated to an article; label IDs belong to a user
articleintegernotnullreferencesarsse_articles(id)ondeletecascade,-- article associated to a label
subscriptionintegernotnullreferencesarsse_subscriptions(id)ondeletecascade,-- Subscription is included so that records are deleted when a subscription is removed
assignedbooleannotnulldefault1,-- whether the association is current, to support soft deletion
assignedintnotnulldefault1,-- whether the association is current, to support soft deletion
modifiedtextnotnulldefaultCURRENT_TIMESTAMP,-- time at which the association was last made or unmade
primarykey(label,article)-- only one association of a given label to a given article
)withoutrowid;
insertintoarsse_label_members_new
select
label,m.id,assigned,l.modified
fromarsse_articles_mapasm
joinarsse_label_membersaslusing(article);
-- Create a new subscriptions table which combines the feeds table
-- Fix up the tag members table
-- Fix up the icons table
createtablearsse_subscriptions_new(
-- users' subscriptions to newsfeeds, with settings
idintegerprimarykey,-- sequence number
ownertextnotnullreferencesarsse_users(id)ondeletecascadeonupdatecascade,-- owner of subscription
urltextnotnull,-- URL of feed
feed_titletextnotnullcollatenocase,-- feed title
titletextcollatenocase,-- user-supplied title, which overrides the feed title when set
folderintegerreferencesarsse_folders(id)ondeletecascade,-- TT-RSS category (nestable); the first-level category (which acts as Nextcloud folder) is joined in when needed
last_modtext,-- time at which the feed last actually changed at the foreign host
etagtextnotnulldefault'',-- HTTP ETag hash used for cache validation, changes each time the content changes
next_fetchtext,-- time at which the feed should next be fetched
addedtextnotnulldefaultCURRENT_TIMESTAMP,-- time at which feed was added
sourcetext,-- URL of site to which the feed belongs
updatedtext,-- time at which the feed was last fetched
err_countintegernotnulldefault0,-- count of successive times update resulted in error since last successful update
err_msgtext,-- last error message
sizeintegernotnulldefault0,-- number of articles in the feed at last fetch
iconintegerreferencesarsse_icons(id)ondeletesetnull,-- numeric identifier of any associated icon
modifiedtextnotnulldefaultCURRENT_TIMESTAMP,-- time at which subscription properties were last modified by the user
order_typeintnotnulldefault0,-- Nextcloud sort order
pinnedintnotnulldefault0,-- whether feed is pinned (always sorts at top)
unique(owner,url)-- a URL with particular credentials should only appear once