DB structures for #31.

This commit is contained in:
Martin Rotter 2020-06-22 10:57:36 +02:00
parent 5f1af487ad
commit 3d59187937
4 changed files with 67 additions and 3 deletions

View File

@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS Information (
inf_value TEXT NOT NULL
);
-- !
INSERT INTO Information VALUES (1, 'schema_version', '14');
INSERT INTO Information VALUES (1, 'schema_version', '15');
-- !
CREATE TABLE IF NOT EXISTS Accounts (
id INTEGER PRIMARY KEY,
@ -127,4 +127,21 @@ CREATE TABLE IF NOT EXISTS Messages (
custom_hash TEXT,
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
);
-- !
CREATE TABLE IF NOT EXISTS MessageFilters (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL CHECK (name != ''),
script TEXT NOT NULL CHECK (script != '')
);
-- !
CREATE TABLE IF NOT EXISTS MessageFiltersInFeeds (
filter INTEGER NOT NULL,
feed_custom_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
FOREIGN KEY (filter) REFERENCES MessageFilters (id) ON DELETE CASCADE,
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
);
-- !
UPDATE Information SET inf_value = '15' WHERE inf_key = 'schema_version';

View File

@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS Information (
inf_value TEXT NOT NULL
);
-- !
INSERT INTO Information VALUES (1, 'schema_version', '14');
INSERT INTO Information VALUES (1, 'schema_version', '15');
-- !
CREATE TABLE IF NOT EXISTS Accounts (
id INTEGER PRIMARY KEY,
@ -121,4 +121,19 @@ CREATE TABLE IF NOT EXISTS Messages (
custom_hash TEXT,
FOREIGN KEY (account_id) REFERENCES Accounts (id)
);
-- !
CREATE TABLE IF NOT EXISTS MessageFilters (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL CHECK (name != ''),
script TEXT NOT NULL CHECK (script != '')
);
-- !
CREATE TABLE IF NOT EXISTS MessageFiltersInFeeds (
filter INTEGER NOT NULL,
feed_custom_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
FOREIGN KEY (filter) REFERENCES MessageFilters (id) ON DELETE CASCADE,
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
);

View File

@ -0,0 +1,16 @@
CREATE TABLE IF NOT EXISTS MessageFilters (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL CHECK (name != ''),
script TEXT NOT NULL CHECK (script != '')
);
-- !
CREATE TABLE IF NOT EXISTS MessageFiltersInFeeds (
filter INTEGER NOT NULL,
feed_custom_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
FOREIGN KEY (filter) REFERENCES MessageFilters (id) ON DELETE CASCADE,
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
);
-- !
UPDATE Information SET inf_value = '15' WHERE inf_key = 'schema_version';

View File

@ -0,0 +1,16 @@
CREATE TABLE IF NOT EXISTS MessageFilters (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL CHECK (name != ''),
script TEXT NOT NULL CHECK (script != '')
);
-- !
CREATE TABLE IF NOT EXISTS MessageFiltersInFeeds (
filter INTEGER NOT NULL,
feed_custom_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
FOREIGN KEY (filter) REFERENCES MessageFilters (id) ON DELETE CASCADE,
FOREIGN KEY (account_id) REFERENCES Accounts (id) ON DELETE CASCADE
);
-- !
UPDATE Information SET inf_value = '15' WHERE inf_key = 'schema_version';