From 076a132c0fc389d8af0a1e2ba33964578b9186d5 Mon Sep 17 00:00:00 2001 From: senke Date: Tue, 24 Feb 2026 09:51:21 +0100 Subject: [PATCH] feat(live): add migration 117 and model fields for Go Live --- veza-backend-api/internal/models/live_stream.go | 5 ++++- .../migrations/117_live_streams_go_live.sql | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 veza-backend-api/migrations/117_live_streams_go_live.sql diff --git a/veza-backend-api/internal/models/live_stream.go b/veza-backend-api/internal/models/live_stream.go index 99e15417f..e4dbd6000 100644 --- a/veza-backend-api/internal/models/live_stream.go +++ b/veza-backend-api/internal/models/live_stream.go @@ -22,7 +22,10 @@ type LiveStream struct { EndedAt *time.Time `json:"endedAt" db:"ended_at"` ViewerCount int `gorm:"default:0" json:"viewers" db:"viewer_count"` Tags []string `gorm:"type:jsonb;default:'[]'" json:"tags" db:"tags"` - CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" db:"created_at"` + ScheduledAt *time.Time `json:"scheduled_at,omitempty" db:"scheduled_at"` + StreamURL string `gorm:"type:text;default:''" json:"stream_url,omitempty" db:"stream_url"` + IsVOD bool `gorm:"default:false" json:"is_vod" db:"is_vod"` + CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at" db:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at" db:"updated_at"` DeletedAt gorm.DeletedAt `json:"-" db:"deleted_at"` diff --git a/veza-backend-api/migrations/117_live_streams_go_live.sql b/veza-backend-api/migrations/117_live_streams_go_live.sql new file mode 100644 index 000000000..db24ed131 --- /dev/null +++ b/veza-backend-api/migrations/117_live_streams_go_live.sql @@ -0,0 +1,16 @@ +-- v0.703: Go Live — scheduled_at, stream_url, is_vod, stream_key NOT NULL +ALTER TABLE live_streams + ADD COLUMN IF NOT EXISTS scheduled_at TIMESTAMPTZ, + ADD COLUMN IF NOT EXISTS stream_url TEXT DEFAULT '', + ADD COLUMN IF NOT EXISTS is_vod BOOLEAN NOT NULL DEFAULT false; + +UPDATE live_streams SET stream_key = gen_random_uuid()::text + WHERE stream_key = '' OR stream_key IS NULL; + +ALTER TABLE live_streams ALTER COLUMN stream_key SET NOT NULL; +ALTER TABLE live_streams ALTER COLUMN stream_key SET DEFAULT gen_random_uuid()::text; + +CREATE INDEX IF NOT EXISTS idx_live_streams_user_id ON live_streams(user_id); +CREATE INDEX IF NOT EXISTS idx_live_streams_is_live ON live_streams(is_live) WHERE is_live = true; +CREATE INDEX IF NOT EXISTS idx_live_streams_scheduled ON live_streams(scheduled_at) + WHERE scheduled_at IS NOT NULL;