Files
silo-server/migrations/150_abs_collection_items.up.sql
T
RXWatcherandClaude Opus 4.7 54c6a3b979 feat(audiobooks): add abs_user_collections + abs_collection_items migrations
Migrations 149 + 150 back the upcoming ABS collection endpoints.
Schema rationale documented in
docs/superpowers/specs/2026-05-26-abs-collections-playlists-design.md
§5.1, §5.2, §5.5.

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

14 lines
663 B
SQL

-- Items inside an abs_user_collections row. Composite PK rules out
-- duplicates. Both FKs cascade so a deleted collection or a deleted
-- media item silently drops the membership row.
CREATE TABLE IF NOT EXISTS public.abs_collection_items (
collection_id text NOT NULL REFERENCES public.abs_user_collections(id) ON DELETE CASCADE,
library_item_id text NOT NULL REFERENCES public.media_items(content_id) ON DELETE CASCADE,
added_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (collection_id, library_item_id)
);
CREATE INDEX IF NOT EXISTS abs_collection_items_library_item_idx
ON public.abs_collection_items (library_item_id);