2026-05-24 12:11:30 +02:00
|
|
|
-- 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.
|
2026-05-24 12:06:04 +02:00
|
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS public.abs_sessions (
|
2026-05-24 12:11:30 +02:00
|
|
|
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
|
2026-05-24 12:06:04 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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);
|