2017-11-17 01:51:03 +00:00
-- SPDX-License-Identifier: MIT
-- Copyright 2017 J. King, Dustin Wilson et al.
-- See LICENSE and AUTHORS files for details
2019-01-21 15:40:39 +00:00
create table arsse_sessions (
2018-11-23 17:53:56 +00:00
-- sessions for Tiny Tiny RSS (and possibly others)
2017-09-16 23:57:33 +00:00
id text primary key , -- UUID of session
2017-10-05 21:42:12 +00:00
created text not null default CURRENT_TIMESTAMP , -- Session start timestamp
expires text not null , -- Time at which session is no longer valid
2017-09-24 16:45:07 +00:00
user text not null references arsse_users ( id ) on delete cascade on update cascade -- user associated with the session
2017-09-16 23:57:33 +00:00
) without rowid ;
2019-01-21 15:40:39 +00:00
create table arsse_labels (
2018-11-23 17:53:56 +00:00
-- user-defined article labels for Tiny Tiny RSS
2017-09-16 23:57:33 +00:00
id integer primary key , -- numeric ID
owner text not null references arsse_users ( id ) on delete cascade on update cascade , -- owning user
name text not null , -- label text
2017-10-05 21:42:12 +00:00
modified text not null default CURRENT_TIMESTAMP , -- time at which the label was last modified
2017-09-16 23:57:33 +00:00
unique ( owner , name )
) ;
2019-01-21 15:40:39 +00:00
create table arsse_label_members (
2019-03-03 17:10:18 +00:00
-- label assignments for articles
2018-11-23 17:53:56 +00:00
label integer not null references arsse_labels ( id ) on delete cascade , -- label ID associated to an article; label IDs belong to a user
article integer not null references arsse_articles ( id ) on delete cascade , -- article associated to a label
2017-09-16 23:57:33 +00:00
subscription integer not null references arsse_subscriptions ( id ) on delete cascade , -- Subscription is included so that records are deleted when a subscription is removed
2018-11-23 17:53:56 +00:00
assigned boolean not null default 1 , -- whether the association is current, to support soft deletion
modified text not null default CURRENT_TIMESTAMP , -- time at which the association was last made or unmade
primary key ( label , article ) -- only one association of a given label to a given article
2017-09-16 23:57:33 +00:00
) without rowid ;
2017-11-09 19:21:12 +00:00
-- alter marks table to add Tiny Tiny RSS' notes
2018-11-23 17:53:56 +00:00
-- SQLite has limited ALTER TABLE support, so the table must be re-created
-- and its data re-entered; other database systems have a much simpler prodecure
2019-01-21 15:40:39 +00:00
create table arsse_marks_new (
2018-11-23 17:53:56 +00:00
-- users' actions on newsfeed entries
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
note text not null default ' ' , -- Tiny Tiny RSS freeform user note
primary key ( article , subscription ) -- no more than one mark-set per article per user
2017-11-09 19:21:12 +00:00
) ;
2019-01-21 15:40:39 +00:00
insert into arsse_marks_new ( article , subscription , read , starred , modified ) select article , subscription , read , starred , modified from arsse_marks ;
drop table arsse_marks ;
alter table arsse_marks_new rename to arsse_marks ;
2017-11-09 19:21:12 +00:00
2017-09-16 23:57:33 +00:00
-- set version marker
pragma user_version = 2 ;
2019-03-03 17:10:18 +00:00
update arsse_meta set value = ' 2 ' where " key " = ' schema_version ' ;