5 CREATE TABLE IF NOT EXISTS channels(
8 CREATE TABLE IF NOT EXISTS playlists(
12 CREATE TABLE IF NOT EXISTS subscriptions(
13 channel_id STRING
, -- TODO: rename so it makes sense for playlists
15 type TEXT DEFAULT 'channel' NOT NULL CHECK(type IN ('channel', 'playlist')),
16 PRIMARY KEY (channel_id
, user));
17 CREATE TABLE IF NOT EXISTS videos(
18 id STRING
PRIMARY KEY,
22 livestream
BOOLEAN DEFAULT 0,
24 crawled DATETIME
DEFAULT CURRENT_TIMESTAMP);
25 CREATE TABLE IF NOT EXISTS playlist_videos(
28 PRIMARY KEY (video_id
, playlist_id
));
29 CREATE TABLE IF NOT EXISTS crawler(
30 channel_id STRING
PRIMARY KEY, -- TODO: rename so it makes sense for playlists
31 crawled_at DATETIME
DEFAULT CURRENT_TIMESTAMP);
32 CREATE TABLE IF NOT EXISTS websub(
33 channel_id STRING
PRIMARY KEY,
34 subscribed_until DATETIME
DEFAULT CURRENT_TIMESTAMP,
35 pending
BOOLEAN DEFAULT 0);
36 CREATE TABLE IF NOT EXISTS flags(
39 display
TEXT CHECK(display
IN (NULL, 'pinned', 'hidden')),
40 PRIMARY KEY (user, video_id
));
46 CREATE TABLE IF NOT EXISTS subreddits(
47 subreddit STRING
COLLATE NOCASE
, -- e.g. videos (not /r/...)
49 PRIMARY KEY (subreddit
, user));
55 CREATE TABLE IF NOT EXISTS captcha_requests(
59 timestamp DATETIME
DEFAULT CURRENT_TIMESTAMP);
60 CREATE TABLE IF NOT EXISTS captcha_cookies(
68 CREATE TABLE IF NOT EXISTS users(
69 id INTEGER PRIMARY KEY AUTOINCREMENT
,
70 name TEXT NOT NULL UNIQUE,
71 password TEXT NOT NULL,
72 token TEXT NOT NULL); -- TODO: deprecated; use users.id instead
73 CREATE TABLE IF NOT EXISTS user_tokens( -- stores revocable url tokens for feeds.
74 user_id
INTEGER PRIMARY KEY NOT NULL,