-- Bookmarks store. Rows accumulate so the feed keeps tweets even after they
-- scroll out of X's 100-item bookmarks API window.
CREATE TABLE IF NOT EXISTS bookmarks (
  id         TEXT PRIMARY KEY,   -- tweet id
  text       TEXT NOT NULL,
  author_id  TEXT,
  username   TEXT,
  name       TEXT,
  created_at TEXT,               -- ISO 8601 from X
  media_urls TEXT,               -- JSON array of media URLs
  url        TEXT,               -- permalink
  fetched_at INTEGER NOT NULL    -- epoch ms when first stored
);
CREATE INDEX IF NOT EXISTS idx_bookmarks_created ON bookmarks(created_at DESC);

-- Tiny key/value table for OAuth tokens, user id, PKCE verifiers, and last_sync.
CREATE TABLE IF NOT EXISTS meta (
  key   TEXT PRIMARY KEY,
  value TEXT NOT NULL
);
