From 469e469dd3f77bc8cd22bbcd87017eb69569ac23 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Mon, 27 Oct 2025 01:32:19 +0900
Subject: feat(backend): Create users table

---
 backend/db/schema.sql | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

(limited to 'backend/db/schema.sql')

diff --git a/backend/db/schema.sql b/backend/db/schema.sql
index eb40dea..e1260b0 100644
--- a/backend/db/schema.sql
+++ b/backend/db/schema.sql
@@ -1,10 +1,19 @@
+-- Users
+CREATE TABLE IF NOT EXISTS users (
+    id            INTEGER PRIMARY KEY AUTOINCREMENT,
+    username      TEXT NOT NULL UNIQUE,
+    password_hash TEXT NOT NULL,
+    created_at    TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
 -- 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,
-    is_subscribed INTEGER NOT NULL DEFAULT 1
+    is_subscribed INTEGER NOT NULL DEFAULT 1,
+    user_id       INTEGER REFERENCES users(id) ON DELETE CASCADE
 );
 
 -- Articles
@@ -24,3 +33,5 @@ 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);
+
+CREATE INDEX IF NOT EXISTS idx_feeds_user_id ON feeds(user_id);
-- 
cgit v1.2.3-70-g09d2

