2017-11-17 01:23:18 +00:00
-- SPDX-License-Identifier: MIT
-- Copyright 2017 J. King, Dustin Wilson et al.
-- See LICENSE and AUTHORS files for details
2017-07-07 15:49:54 +00:00
-- metadata
create table arsse_meta (
key text primary key not null , -- metadata key
value text -- metadata value, serialized as a string
) ;
2017-03-07 23:01:13 +00:00
-- users
2017-03-28 04:12:12 +00:00
create table arsse_users (
2017-07-07 15:49:54 +00: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 13:15:44 +00: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 15:49:54 +00:00
) ;
2017-07-11 13:15:44 +00:00
-- extra user metadata
create table arsse_users_meta (
owner text not null references arsse_users ( id ) on delete cascade on update cascade ,
key text not null ,
value text ,
primary key ( owner , key )
) ;
-- NextCloud News folders
2017-07-07 15:49:54 +00:00
create table arsse_folders (
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
2017-07-15 17:33:17 +00:00
modified text not null default CURRENT_TIMESTAMP , --
2017-07-07 15:49:54 +00:00
unique ( owner , name , parent ) -- cannot have multiple folders with the same name under the same parent for the same owner
) ;
2017-03-07 23:01:13 +00:00
2016-10-18 15:42:21 +00:00
-- newsfeeds, deduplicated
2017-03-28 04:12:12 +00:00
create table arsse_feeds (
2017-04-14 02:17:53 +00:00
id integer primary key , -- sequence number
2017-07-07 15:49:54 +00:00
url text not null , -- URL of feed
title text , -- default title of feed
favicon text , -- URL of favicon
source text , -- URL of site to which the feed belongs
2017-07-15 17:33:17 +00: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
2017-08-02 22:27:04 +00:00
orphaned text , -- time at which the feed last had no subscriptions
2017-07-07 15:49:54 +00:00
etag text not null default ' ' , -- HTTP ETag hash used for cache validation, changes each time the content changes
2017-02-16 20:29:42 +00:00
err_count integer not null default 0 , -- count of successive times update resulted in error since last successful update
2017-07-07 15:49:54 +00: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 18:56:50 +00: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 20:29:42 +00:00
unique ( url , username , password ) -- a URL with particular credentials should only appear once
2016-10-18 15:42:21 +00:00
) ;
2017-03-07 23:01:13 +00:00
-- users' subscriptions to newsfeeds, with settings
2017-03-28 04:12:12 +00:00
create table arsse_subscriptions (
2017-04-14 02:17:53 +00:00
id integer primary key , -- sequence number
2017-07-07 15:49:54 +00:00
owner text not null references arsse_users ( id ) on delete cascade on update cascade , -- owner of subscription
2017-03-31 19:27:59 +00:00
feed integer not null references arsse_feeds ( id ) on delete cascade , -- feed for the subscription
2017-07-15 17:33:17 +00:00
added text not null default CURRENT_TIMESTAMP , -- time at which feed was added
modified text not null default CURRENT_TIMESTAMP , -- date at which subscription properties were last modified
2017-07-07 15:49:54 +00:00
title text , -- user-supplied title
2017-03-18 16:01:23 +00:00
order_type int not null default 0 , -- NextCloud sort order
2017-03-07 23:01:13 +00:00
pinned boolean not null default 0 , -- whether feed is pinned (always sorts at top)
2017-03-31 19:27:59 +00: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 23:01:13 +00:00
unique ( owner , feed ) -- a given feed should only appear once for a given owner
) ;
2016-10-18 15:42:21 +00:00
-- entries in newsfeeds
2017-03-28 04:12:12 +00:00
create table arsse_articles (
2017-04-14 02:17:53 +00:00
id integer primary key , -- sequence number
2017-03-31 19:27:59 +00:00
feed integer not null references arsse_feeds ( id ) on delete cascade , -- feed for the subscription
2017-07-07 15:49:54 +00:00
url text , -- URL of article
title text , -- article title
author text , -- author's name
2017-07-15 17:33:17 +00:00
published text , -- time of original publication
edited text , -- time of last edit
modified text not null default CURRENT_TIMESTAMP , -- date when article properties were last modified
2017-07-07 15:49:54 +00: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 15:42:21 +00:00
) ;
-- enclosures associated with articles
2017-03-28 04:12:12 +00:00
create table arsse_enclosures (
article integer not null references arsse_articles ( id ) on delete cascade ,
2017-07-07 15:49:54 +00:00
url text ,
type text
2016-10-18 15:42:21 +00:00
) ;
-- users' actions on newsfeed entries
2017-05-17 02:19:40 +00:00
create table arsse_marks (
2017-03-28 04:12:12 +00:00
article integer not null references arsse_articles ( id ) on delete cascade ,
2017-08-14 21:18:18 +00:00
subscription integer not null references arsse_subscriptions ( id ) on delete cascade on update cascade ,
2017-02-16 20:29:42 +00:00
read boolean not null default 0 ,
starred boolean not null default 0 ,
2017-07-15 17:33:17 +00:00
modified text not null default CURRENT_TIMESTAMP ,
2017-08-14 21:18:18 +00:00
primary key ( article , subscription )
2016-10-18 15:42:21 +00:00
) ;
2017-04-14 02:17:53 +00:00
-- IDs for specific editions of articles (required for at least NextCloud News)
create table arsse_editions (
id integer primary key ,
2017-05-19 03:03:33 +00:00
article integer not null references arsse_articles ( id ) on delete cascade ,
modified datetime not null default CURRENT_TIMESTAMP
2017-04-14 02:17:53 +00:00
) ;
2017-03-30 14:42:37 +00:00
-- author categories associated with newsfeed entries
create table arsse_categories (
2017-03-28 04:12:12 +00:00
article integer not null references arsse_articles ( id ) on delete cascade ,
2017-07-07 15:49:54 +00:00
name text
2017-03-07 23:01:13 +00:00
) ;
2016-10-18 15:42:21 +00:00
-- set version marker
pragma user_version = 1 ;
2017-07-07 15:49:54 +00:00
insert into arsse_meta ( key , value ) values ( ' schema_version ' , ' 1 ' ) ;