2025-11-04 21:22:13 +09:00

28 lines
961 B
SQL

-- Create the "current" table and a useful index
CREATE TABLE IF NOT EXISTS "current" (
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
ep_num INTEGER NOT NULL,
ep_title TEXT NOT NULL,
season_name TEXT NOT NULL,
start_time TIME NOT NULL,
playback_length INTERVAL NOT NULL,
current_ep BOOLEAN NOT NULL DEFAULT FALSE,
date_created TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS current_date_created_idx
ON "current" (date_created DESC);
-- Archive table (no identity; just store the id from "current")
CREATE TABLE IF NOT EXISTS current_archive (
id BIGINT NOT NULL,
ep_num INTEGER NOT NULL,
ep_title TEXT NOT NULL,
season_name TEXT NOT NULL,
start_time TIME NOT NULL,
playback_length INTERVAL NOT NULL,
current_ep BOOLEAN NOT NULL DEFAULT FALSE,
date_created TIMESTAMPTZ NOT NULL DEFAULT NOW(),
date_archived TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT current_archive_pkey PRIMARY KEY (id)
);