aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/db/migrations/003_add_users_table.sql
blob: 4cf963ba7eb0709da88115e54a21c4e6ed87ace5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- Add users table and user_id column to feeds table.

-- 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
);

-- Add user_id to feeds table
ALTER TABLE feeds ADD COLUMN user_id INTEGER REFERENCES users(id) ON DELETE CASCADE;

-- Index for feeds.user_id
CREATE INDEX IF NOT EXISTS idx_feeds_user_id ON feeds(user_id);