aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/sqlite.init.sql
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-14 15:44:02 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-14 15:44:02 -0800
commit701e0e8e919d2929ecc98b555e468bd29bf606cf (patch)
treee78856b8ffc83406499b34bb7fdf0892dd2ce6b4 /scripts/sqlite.init.sql
parent17fd19c8f822ff84b1855d7729a3030ebf1f68ae (diff)
downloadneko-701e0e8e919d2929ecc98b555e468bd29bf606cf.tar.gz
neko-701e0e8e919d2929ecc98b555e468bd29bf606cf.tar.bz2
neko-701e0e8e919d2929ecc98b555e468bd29bf606cf.zip
Cleanup root directory by moving scripts to scripts/ and fix CSRF cookie policy for dev env
Diffstat (limited to 'scripts/sqlite.init.sql')
-rw-r--r--scripts/sqlite.init.sql46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/sqlite.init.sql b/scripts/sqlite.init.sql
new file mode 100644
index 0000000..8992483
--- /dev/null
+++ b/scripts/sqlite.init.sql
@@ -0,0 +1,46 @@
+CREATE TABLE feed (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ url varchar(100) NOT NULL UNIQUE,
+ web_url varchar(255) NOT NULL DEFAULT '',
+ title varchar(255) NOT NULL DEFAULT '',
+ last_updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ category varchar(255) NOT NULL DEFAULT 'uncategorized'
+);
+CREATE INDEX feed_url ON feed (url);
+CREATE INDEX feed_category ON feed (category);
+
+CREATE TABLE item (
+ id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
+ feed_id int(11) NOT NULL,
+ title text NOT NULL DEFAULT '',
+ url varchar(255) NOT NULL UNIQUE,
+ description text NOT NULL DEFAULT '',
+ publish_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ read_state tinyint(1) NOT NULL DEFAULT '0',
+ starred tinyint(1) NOT NULL DEFAULT '0',
+ full_content text NOT NULL DEFAULT '',
+ header_image text NOT NULL DEFAULT '',
+ CONSTRAINT item_ibfk_1 FOREIGN KEY (feed_id) REFERENCES feed(id) ON DELETE CASCADE
+);
+CREATE INDEX item_url ON item (url);
+CREATE INDEX item_publish_date ON item (publish_date);
+CREATE INDEX item_feed_id ON item (feed_id);
+CREATE INDEX item_read_state ON item (read_state);
+
+CREATE VIRTUAL TABLE fts_item using fts4(content="item", title, url, description);
+
+INSERT INTO fts_item(fts_item) VALUES('rebuild');
+
+
+CREATE TRIGGER item_bu BEFORE UPDATE ON item BEGIN
+ DELETE FROM fts_item WHERE docid=old.rowid;
+END;
+CREATE TRIGGER item_bd BEFORE DELETE ON item BEGIN
+ DELETE FROM fts_item WHERE docid=old.rowid;
+END;
+CREATE TRIGGER item_au AFTER UPDATE ON item BEGIN
+ INSERT INTO fts_item(docid, title, url, description) VALUES(new.rowid, new.title, new.url, new.description);
+END;
+CREATE TRIGGER item_ai AFTER INSERT ON item BEGIN
+ INSERT INTO fts_item(docid, title, url, description) VALUES(new.rowid, new.title, new.url, new.description);
+END;