Files
silo-server/migrations/147_abs_sessions.up.sql
T
RXWatcherandClaude Opus 4.7 d59c1cb0b4 chore(migrations): renumber 139_abs_sessions to 147 for origin/main merge
origin/main adds 139_media_requests at the same number our local
audiobook branch had used for abs_sessions. Renumber ours to 147 to
free up 139 for the upstream migration. The schema_versions row is
updated in lockstep on the running database so the migrator sees the
abs_sessions migration as already applied at its new version.

Migrations 140-146 (podcast feeds, media_folders kind noop, audiobook
feature flag, abs playback sessions, podcast episode guid, audiobook
series, audiobook title cleanup) stay where they are — they don't
collide with anything on origin/main.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 19:48:15 +02:00

27 lines
1002 B
SQL

-- Audiobookshelf-compatible client sessions. Same role as
-- jellycompat_sessions (compat-layer token store) but with a proper
-- users FK, device metadata, and soft revocation via revoked_at instead
-- of hard expiry.
CREATE TABLE IF NOT EXISTS public.abs_sessions (
id bigserial PRIMARY KEY,
user_id integer NOT NULL REFERENCES public.users(id) ON DELETE CASCADE,
token text NOT NULL,
device_id text NOT NULL,
device_name text,
client_name text,
client_version text,
created_at timestamp with time zone NOT NULL DEFAULT now(),
last_seen_at timestamp with time zone NOT NULL DEFAULT now(),
revoked_at timestamp with time zone
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_abs_sessions_token
ON public.abs_sessions (token);
CREATE INDEX IF NOT EXISTS idx_abs_sessions_user_device
ON public.abs_sessions (user_id, device_id);
CREATE INDEX IF NOT EXISTS idx_abs_sessions_last_seen
ON public.abs_sessions (last_seen_at);