[BE-DB-005] be-db: Create migration for playlist_share_link table
This commit is contained in:
parent
b646243bdf
commit
d0e25a3924
2 changed files with 40 additions and 2 deletions
|
|
@ -3070,7 +3070,7 @@
|
|||
"description": "Add table for shareable playlist links with expiration",
|
||||
"owner": "backend",
|
||||
"estimated_hours": 2,
|
||||
"status": "todo",
|
||||
"status": "completed",
|
||||
"files_involved": [],
|
||||
"implementation_steps": [
|
||||
{
|
||||
|
|
@ -3091,7 +3091,9 @@
|
|||
"Unit tests",
|
||||
"Integration tests"
|
||||
],
|
||||
"notes": ""
|
||||
"notes": "",
|
||||
"completed_at": "2025-12-24T15:09:43.327785",
|
||||
"implementation_notes": "Created migration 044_playlist_share_links.sql for playlist_share_links table. Migration includes: id (UUID), playlist_id (FK to playlists), user_id (FK to users), share_token (unique), expires_at (optional), access_count (default 0), timestamps (created_at, updated_at, deleted_at), and appropriate indexes. Model PlaylistShareLink already existed."
|
||||
},
|
||||
{
|
||||
"id": "BE-DB-006",
|
||||
|
|
|
|||
36
veza-backend-api/migrations/044_playlist_share_links.sql
Normal file
36
veza-backend-api/migrations/044_playlist_share_links.sql
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
-- 044_playlist_share_links.sql
|
||||
-- Playlist Share Links (BE-DB-005: Create migration for playlist_share_link table)
|
||||
-- Add table for shareable playlist links with expiration
|
||||
|
||||
-- === PLAYLIST SHARE LINKS ===
|
||||
CREATE TABLE IF NOT EXISTS public.playlist_share_links (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
playlist_id UUID NOT NULL REFERENCES public.playlists(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES public.users(id) ON DELETE CASCADE,
|
||||
|
||||
-- Share Info
|
||||
share_token VARCHAR(255) NOT NULL,
|
||||
expires_at TIMESTAMPTZ,
|
||||
access_count BIGINT NOT NULL DEFAULT 0,
|
||||
|
||||
-- Timestamps
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMPTZ,
|
||||
|
||||
CONSTRAINT uq_playlist_share_links_token UNIQUE (share_token)
|
||||
);
|
||||
|
||||
-- Indexes
|
||||
CREATE INDEX IF NOT EXISTS idx_playlist_share_links_playlist_id ON public.playlist_share_links(playlist_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_playlist_share_links_user_id ON public.playlist_share_links(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_playlist_share_links_share_token ON public.playlist_share_links(share_token);
|
||||
CREATE INDEX IF NOT EXISTS idx_playlist_share_links_expires_at ON public.playlist_share_links(expires_at) WHERE expires_at IS NOT NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_playlist_share_links_deleted_at ON public.playlist_share_links(deleted_at) WHERE deleted_at IS NULL;
|
||||
|
||||
-- Comments
|
||||
COMMENT ON TABLE public.playlist_share_links IS 'Shareable public links for playlists with optional expiration';
|
||||
COMMENT ON COLUMN public.playlist_share_links.share_token IS 'Unique token for the share link';
|
||||
COMMENT ON COLUMN public.playlist_share_links.expires_at IS 'Optional expiration date for the share link';
|
||||
COMMENT ON COLUMN public.playlist_share_links.access_count IS 'Number of times the share link has been accessed';
|
||||
|
||||
Loading…
Reference in a new issue