From fbe4bff7e8b6a5239c490601436fb3638dc8e13b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 12 Jul 2025 17:11:13 +0900 Subject: feat(backend): introduce sqlc --- backend/db/schema.sql | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 backend/db/schema.sql (limited to 'backend/db/schema.sql') diff --git a/backend/db/schema.sql b/backend/db/schema.sql new file mode 100644 index 0000000..5c2bf48 --- /dev/null +++ b/backend/db/schema.sql @@ -0,0 +1,25 @@ +-- Feeds +CREATE TABLE IF NOT EXISTS feeds ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + url TEXT NOT NULL, + title TEXT NOT NULL, + fetched_at TEXT NOT NULL +); + +-- Articles +CREATE TABLE IF NOT EXISTS articles ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + feed_id INTEGER NOT NULL, + guid TEXT NOT NULL, + title TEXT NOT NULL, + url TEXT NOT NULL, + is_read INTEGER NOT NULL DEFAULT 0, + FOREIGN KEY (feed_id) REFERENCES feeds(id) ON DELETE CASCADE +); + +-- Indice +CREATE INDEX IF NOT EXISTS idx_articles_feed_id ON articles(feed_id); + +CREATE INDEX IF NOT EXISTS idx_articles_feed_guid ON articles(feed_id, guid); + +CREATE INDEX IF NOT EXISTS idx_articles_is_read ON articles(is_read); -- cgit v1.2.3-70-g09d2