2017-11-16 20:23:18 -05:00
-- SPDX-License-Identifier: MIT
-- Copyright 2017 J. King, Dustin Wilson et al.
-- See LICENSE and AUTHORS files for details
2017-07-07 11:49:54 -04:00
create table arsse_meta (
2018-11-23 12:53:56 -05:00
-- application metadata
2017-07-07 11:49:54 -04:00
key text primary key not null , -- metadata key
value text -- metadata value, serialized as a string
) ;
2017-03-07 18:01:13 -05:00
2017-03-28 00:12:12 -04:00
create table arsse_users (
2018-11-23 12:53:56 -05:00
-- users
2017-07-07 11:49:54 -04:00
id text primary key not null , -- user id
password text , -- password, salted and hashed; if using external authentication this would be blank
name text , -- display name
avatar_type text , -- internal avatar image's MIME content type
avatar_data blob , -- internal avatar image's binary data
2017-07-11 09:15:44 -04:00
admin boolean default 0 , -- whether the user is a member of the special "admin" group
rights integer not null default 0 -- temporary admin-rights marker FIXME: remove reliance on this
2017-07-07 11:49:54 -04:00
) ;
2017-07-11 09:15:44 -04:00
create table arsse_users_meta (
2018-11-23 12:53:56 -05:00
-- extra user metadata (not currently used and will be removed)
2017-07-11 09:15:44 -04:00
owner text not null references arsse_users ( id ) on delete cascade on update cascade ,
key text not null ,
value text ,
primary key ( owner , key )
) ;
2017-07-07 11:49:54 -04:00
create table arsse_folders (
2019-12-05 13:02:02 -05:00
-- folders, used by Nextcloud News and Tiny Tiny RSS
2018-11-23 12:53:56 -05:00
-- feed subscriptions may belong to at most one folder;
-- in Tiny Tiny RSS folders may nest
2017-07-07 11:49:54 -04:00
id integer primary key , -- sequence number
owner text not null references arsse_users ( id ) on delete cascade on update cascade , -- owner of folder
parent integer references arsse_folders ( id ) on delete cascade , -- parent folder id
name text not null , -- folder name
2018-11-23 12:53:56 -05:00
modified text not null default CURRENT_TIMESTAMP , -- time at which the folder itself (not its contents) was changed; not currently used
2017-07-07 11:49:54 -04:00
unique ( owner , name , parent ) -- cannot have multiple folders with the same name under the same parent for the same owner
) ;
2017-03-07 18:01:13 -05:00
2017-03-28 00:12:12 -04:00
create table arsse_feeds (
2018-11-23 12:53:56 -05:00
-- newsfeeds, deduplicated
-- users have subscriptions to these feeds in another table
2017-04-13 22:17:53 -04:00
id integer primary key , -- sequence number
2017-07-07 11:49:54 -04:00
url text not null , -- URL of feed
2018-11-23 12:53:56 -05:00
title text , -- default title of feed (users can set the title of their subscription to the feed)
2017-07-07 11:49:54 -04:00
favicon text , -- URL of favicon
source text , -- URL of site to which the feed belongs
2017-07-15 13:33:17 -04:00
updated text , -- time at which the feed was last fetched
modified text , -- time at which the feed last actually changed
next_fetch text , -- time at which the feed should next be fetched
2018-11-23 12:53:56 -05:00
orphaned text , -- time at which the feed last had no subscriptions
2017-07-07 11:49:54 -04:00
etag text not null default ' ' , -- HTTP ETag hash used for cache validation, changes each time the content changes
2017-02-16 15:29:42 -05:00
err_count integer not null default 0 , -- count of successive times update resulted in error since last successful update
2017-07-07 11:49:54 -04:00
err_msg text , -- last error message
username text not null default ' ' , -- HTTP authentication username
password text not null default ' ' , -- HTTP authentication password (this is stored in plain text)
2017-07-17 14:56:50 -04:00
size integer not null default 0 , -- number of articles in the feed at last fetch
scrape boolean not null default 0 , -- whether to use picoFeed's content scraper with this feed
2017-02-16 15:29:42 -05:00
unique ( url , username , password ) -- a URL with particular credentials should only appear once
2016-10-18 11:42:21 -04:00
) ;
2017-03-28 00:12:12 -04:00
create table arsse_subscriptions (
2018-11-23 12:53:56 -05:00
-- users' subscriptions to newsfeeds, with settings
2017-04-13 22:17:53 -04:00
id integer primary key , -- sequence number
2017-07-07 11:49:54 -04:00
owner text not null references arsse_users ( id ) on delete cascade on update cascade , -- owner of subscription
2017-03-31 15:27:59 -04:00
feed integer not null references arsse_feeds ( id ) on delete cascade , -- feed for the subscription
2017-07-15 13:33:17 -04:00
added text not null default CURRENT_TIMESTAMP , -- time at which feed was added
2018-11-23 12:53:56 -05:00
modified text not null default CURRENT_TIMESTAMP , -- time at which subscription properties were last modified
2017-07-07 11:49:54 -04:00
title text , -- user-supplied title
2019-12-05 13:02:02 -05:00
order_type int not null default 0 , -- Nextcloud sort order
2017-03-07 18:01:13 -05:00
pinned boolean not null default 0 , -- whether feed is pinned (always sorts at top)
2019-12-05 13:02:02 -05:00
folder integer references arsse_folders ( id ) on delete cascade , -- TT-RSS category (nestable); the first-level category (which acts as Nextcloud folder) is joined in when needed
2017-03-07 18:01:13 -05:00
unique ( owner , feed ) -- a given feed should only appear once for a given owner
) ;
2017-03-28 00:12:12 -04:00
create table arsse_articles (
2018-11-23 12:53:56 -05:00
-- entries in newsfeeds
2017-04-13 22:17:53 -04:00
id integer primary key , -- sequence number
2017-03-31 15:27:59 -04:00
feed integer not null references arsse_feeds ( id ) on delete cascade , -- feed for the subscription
2017-07-07 11:49:54 -04:00
url text , -- URL of article
title text , -- article title
author text , -- author's name
2017-07-15 13:33:17 -04:00
published text , -- time of original publication
2018-11-23 12:53:56 -05:00
edited text , -- time of last edit by author
modified text not null default CURRENT_TIMESTAMP , -- time when article was last modified in database
2017-07-07 11:49:54 -04:00
content text , -- content, as (X)HTML
guid text , -- GUID
url_title_hash text not null , -- hash of URL + title; used when checking for updates and for identification if there is no guid.
url_content_hash text not null , -- hash of URL + content, enclosure URL, & content type; used when checking for updates and for identification if there is no guid.
title_content_hash text not null -- hash of title + content, enclosure URL, & content type; used when checking for updates and for identification if there is no guid.
2016-10-18 11:42:21 -04:00
) ;
2017-03-28 00:12:12 -04:00
create table arsse_enclosures (
2018-11-23 12:53:56 -05:00
-- enclosures (attachments) associated with articles
article integer not null references arsse_articles ( id ) on delete cascade , -- article to which the enclosure belongs
url text , -- URL of the enclosure
type text -- content-type (MIME type) of the enclosure
2016-10-18 11:42:21 -04:00
) ;
2017-05-16 22:19:40 -04:00
create table arsse_marks (
2018-11-23 12:53:56 -05:00
article integer not null references arsse_articles ( id ) on delete cascade , -- article associated with the marks
subscription integer not null references arsse_subscriptions ( id ) on delete cascade on update cascade , -- subscription associated with the marks; the subscription in turn belongs to a user
read boolean not null default 0 , -- whether the article has been read
starred boolean not null default 0 , -- whether the article is starred
modified text not null default CURRENT_TIMESTAMP , -- time at which an article was last modified by a given user
primary key ( article , subscription ) -- no more than one mark-set per article per user
2016-10-18 11:42:21 -04:00
) ;
2017-04-13 22:17:53 -04:00
create table arsse_editions (
2019-12-05 13:02:02 -05:00
-- IDs for specific editions of articles (required for at least Nextcloud News)
2018-11-23 12:53:56 -05:00
-- every time an article is updated by its author, a new unique edition number is assigned
2019-12-05 13:02:02 -05:00
-- with Nextcloud News this prevents users from marking as read an article which has been
2018-11-23 12:53:56 -05:00
-- updated since the client state was last refreshed
id integer primary key , -- sequence number
article integer not null references arsse_articles ( id ) on delete cascade , -- the article of which this is an edition
modified datetime not null default CURRENT_TIMESTAMP -- tiem at which the edition was modified (practically, when it was created)
2017-04-13 22:17:53 -04:00
) ;
2017-03-30 10:42:37 -04:00
create table arsse_categories (
2018-11-23 12:53:56 -05:00
-- author categories associated with newsfeed entries
-- these are not user-modifiable
article integer not null references arsse_articles ( id ) on delete cascade , -- article associated with the category
name text -- freeform name of the category
2017-03-07 18:01:13 -05:00
) ;
2016-10-18 11:42:21 -04:00
-- set version marker
pragma user_version = 1 ;
2019-03-03 12:10:18 -05:00
insert into arsse_meta ( " key " , value ) values ( ' schema_version ' , ' 1 ' ) ;