-- connect-pg-simple's session store needs this table. It's defined in
-- schema.sql which only runs on first DB init via the postgres entrypoint;
-- on instances bootstrapped via migrations only (no entrypoint init), the
-- table never existed and every login silently failed to persist the
-- session — manifesting as a redirect loop after submitting valid creds.
-- Idempotent so this is safe to re-run.

CREATE TABLE IF NOT EXISTS sessions (
  sid    TEXT PRIMARY KEY,
  sess   JSONB NOT NULL,
  expire TIMESTAMPTZ NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_sessions_expire ON sessions (expire);
