rssguard/resources/sql/db_init_sqlite.sql

102 lines
4.0 KiB
MySQL
Raw Normal View History

2021-02-26 12:35:57 +01:00
CREATE TABLE Information (
inf_key TEXT NOT NULL UNIQUE CHECK (inf_key != ''),
inf_value TEXT
2017-03-13 07:12:38 +01:00
);
-- !
2021-02-26 12:35:57 +01:00
INSERT INTO Information VALUES ('schema_version', '1');
2017-03-13 07:12:38 +01:00
-- !
2021-02-26 12:35:57 +01:00
CREATE TABLE Accounts (
2017-03-13 07:12:38 +01:00
id INTEGER PRIMARY KEY,
2021-02-26 12:35:57 +01:00
type TEXT NOT NULL CHECK (type != ''), /* ID of the account type. Each account defines its own, for example 'ttrss'. */
proxy_type INTEGER NOT NULL DEFAULT 0 CHECK (proxy_type >= 0),
proxy_host TEXT,
proxy_port INTEGER,
proxy_username TEXT,
2021-02-26 12:35:57 +01:00
proxy_password TEXT,
/* Custom column for (serialized) custom account-specific data. */
custom_data TEXT
);
-- !
2021-02-26 12:35:57 +01:00
CREATE TABLE Categories (
2017-03-13 07:12:38 +01:00
id INTEGER PRIMARY KEY,
2021-02-26 12:35:57 +01:00
parent_id INTEGER NOT NULL CHECK (parent_id >= -1), /* Root categories contain -1 here. */
2017-03-13 07:12:38 +01:00
title TEXT NOT NULL CHECK (title != ''),
description TEXT,
2021-03-02 12:02:07 +01:00
date_created INTEGER NOT NULL CHECK (date_created >= 0),
2017-03-13 07:12:38 +01:00
icon BLOB,
account_id INTEGER NOT NULL,
custom_id TEXT,
2021-03-01 20:09:56 +01:00
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
2017-03-13 07:12:38 +01:00
);
-- !
2021-02-26 12:35:57 +01:00
CREATE TABLE Feeds (
2017-03-13 07:12:38 +01:00
id INTEGER PRIMARY KEY,
title TEXT NOT NULL CHECK (title != ''),
description TEXT,
2021-03-02 12:02:07 +01:00
date_created INTEGER NOT NULL CHECK (date_created >= 0),
2017-03-13 07:12:38 +01:00
icon BLOB,
2021-02-26 12:35:57 +01:00
category INTEGER NOT NULL CHECK (category >= -1), /* Root feeds contain -1 here. */
source TEXT,
2017-03-13 07:12:38 +01:00
update_type INTEGER(1) NOT NULL CHECK (update_type >= 0),
2021-02-26 12:35:57 +01:00
update_interval INTEGER NOT NULL DEFAULT 15 CHECK (update_interval >= 1),
2017-03-13 07:12:38 +01:00
account_id INTEGER NOT NULL,
2021-03-02 12:02:07 +01:00
custom_id TEXT NOT NULL CHECK (custom_id != ''), /* Custom ID cannot be empty, it must contain either service-specific ID, or Feeds/id. */
/* Custom column for (serialized) custom account-specific data. */
custom_data TEXT,
2017-03-13 07:12:38 +01:00
2021-03-01 20:09:56 +01:00
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
2017-03-13 07:12:38 +01:00
);
-- !
2021-02-26 12:35:57 +01:00
CREATE TABLE Messages (
2017-03-13 07:12:38 +01:00
id INTEGER PRIMARY KEY,
2021-02-26 12:35:57 +01:00
is_read INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_read >= 0 AND is_read <= 1),
is_important INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_important >= 0 AND is_important <= 1),
2021-03-02 12:02:07 +01:00
is_deleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_deleted >= 0 AND is_deleted <= 1),
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
2021-03-02 14:30:13 +01:00
feed TEXT NOT NULL, /* Points to Feeds/custom_id. */
2017-03-13 07:12:38 +01:00
title TEXT NOT NULL CHECK (title != ''),
url TEXT,
author TEXT,
2021-03-02 12:02:07 +01:00
date_created INTEGER NOT NULL CHECK (date_created >= 0),
2017-03-13 07:12:38 +01:00
contents TEXT,
enclosures TEXT,
account_id INTEGER NOT NULL,
custom_id TEXT,
custom_hash TEXT,
2021-03-01 20:09:56 +01:00
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
2020-06-22 10:57:36 +02:00
);
-- !
2021-02-26 12:35:57 +01:00
CREATE TABLE MessageFilters (
2020-06-22 10:57:36 +02:00
id INTEGER PRIMARY KEY,
name TEXT NOT NULL CHECK (name != ''),
script TEXT NOT NULL CHECK (script != '')
);
-- !
2021-02-26 12:35:57 +01:00
CREATE TABLE MessageFiltersInFeeds (
2020-06-22 10:57:36 +02:00
filter INTEGER NOT NULL,
2021-03-02 12:02:07 +01:00
feed_custom_id TEXT NOT NULL, /* Points to Feeds/custom_id. */
2020-06-22 10:57:36 +02:00
account_id INTEGER NOT NULL,
FOREIGN KEY (filter) REFERENCES MessageFilters (id) ON DELETE CASCADE,
2020-08-13 19:59:05 +02:00
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
);
-- !
2021-02-26 12:35:57 +01:00
CREATE TABLE Labels (
2020-08-13 19:59:05 +02:00
id INTEGER PRIMARY KEY,
name TEXT NOT NULL CHECK (name != ''),
color VARCHAR(7),
custom_id TEXT,
account_id INTEGER NOT NULL,
2021-03-01 20:09:56 +01:00
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
2020-08-13 19:59:05 +02:00
);
-- !
2021-02-26 12:35:57 +01:00
CREATE TABLE LabelsInMessages (
2020-08-13 19:59:05 +02:00
label TEXT NOT NULL, /* Custom ID of label. */
message TEXT NOT NULL, /* Custom ID of message. */
account_id INTEGER NOT NULL,
2020-06-22 10:57:36 +02:00
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
2017-03-13 07:12:38 +01:00
);