feat(live): add migration 117 and model fields for Go Live
This commit is contained in:
parent
da20e83e09
commit
076a132c0f
2 changed files with 20 additions and 1 deletions
|
|
@ -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"`
|
||||
|
||||
|
|
|
|||
16
veza-backend-api/migrations/117_live_streams_go_live.sql
Normal file
16
veza-backend-api/migrations/117_live_streams_go_live.sql
Normal file
|
|
@ -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;
|
||||
Loading…
Reference in a new issue