summaryrefslogtreecommitdiffhomepage
path: root/backend/db/migrations
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-07-13 01:32:23 +0900
committernsfisis <nsfisis@gmail.com>2025-07-13 01:32:23 +0900
commit3754f11c33a6b4ac756a0d89426764fd9032cf53 (patch)
tree47bda36abe8340eb6b0eea988c55a90202436409 /backend/db/migrations
parent732c71f7c2e5f0a37c03c2efedcfa8e5360e3fda (diff)
downloadfeedaka-3754f11c33a6b4ac756a0d89426764fd9032cf53.tar.gz
feedaka-3754f11c33a6b4ac756a0d89426764fd9032cf53.tar.zst
feedaka-3754f11c33a6b4ac756a0d89426764fd9032cf53.zip
feat(backend): implement db schema migrationv0.2.0
Diffstat (limited to 'backend/db/migrations')
-rw-r--r--backend/db/migrations/001_initial_schema.sql27
-rw-r--r--backend/db/migrations/002_add_feeds_is_subscribed.sql3
2 files changed, 30 insertions, 0 deletions
diff --git a/backend/db/migrations/001_initial_schema.sql b/backend/db/migrations/001_initial_schema.sql
new file mode 100644
index 0000000..6f0b75e
--- /dev/null
+++ b/backend/db/migrations/001_initial_schema.sql
@@ -0,0 +1,27 @@
+-- Initial schema
+
+-- 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); \ No newline at end of file
diff --git a/backend/db/migrations/002_add_feeds_is_subscribed.sql b/backend/db/migrations/002_add_feeds_is_subscribed.sql
new file mode 100644
index 0000000..30bb273
--- /dev/null
+++ b/backend/db/migrations/002_add_feeds_is_subscribed.sql
@@ -0,0 +1,3 @@
+-- Add is_subscribed column to feeds table.
+
+ALTER TABLE feeds ADD COLUMN is_subscribed INTEGER NOT NULL DEFAULT 1; \ No newline at end of file