diff --git a/store/migrations.go b/store/migrations.go index d02e07334ef6fb5068d4c63ea8fd4b4d4ac65af4..b86d2f880106c7a6fd80072758722344a0cd898b 100644 --- a/store/migrations.go +++ b/store/migrations.go @@ -144,6 +144,36 @@ var ( return nil }, }, + { + ID: "201908110945", + Migrate: func(tx *gorm.DB) error { + + type PlaylistEntry struct { + ID uint64 `json:"-" gorm:"primary_key"` + PlaylistID uint64 `json:"-" gorm:"not null;index;unique_index:unique_playlist_line_numbers"` + LineNum uint `json:"-" gorm:"not null;unique_index:unique_playlist_line_numbers"` + URI string `json:"uri" gorm:"size:1024"` + File *File `json:"file,omitempty" gorm:"association_autoupdate:false;association_autocreate:false"` + FileID *uint64 `json:"-" gorm:"index"` + } + + type Playlist struct { + ID uint64 `json:"id" gorm:"primary_key"` + CreatedAt time.Time `json:"created"` + UpdatedAt time.Time `json:"updated"` + Description string `json:"description"` + PlayoutMode string `json:"playout-mode"` + ShowName string `json:"show" gorm:"not null;index"` + Show Show `json:"-" gorm:"association_foreignkey:Name"` + Entries []PlaylistEntry `json:"entries,omitempty"` + } + + return tx.AutoMigrate(&Playlist{}).Error + }, + Rollback: func(tx *gorm.DB) error { + return tx.Table("playlists").DropColumn("playout_mode").Error + }, + }, } ) diff --git a/store/types.go b/store/types.go index 6d82447f89183b34947c6b07fb64788cb903bbf6..0e7385514273c818e27fb5000ea2b5fbcd4f1b39 100644 --- a/store/types.go +++ b/store/types.go @@ -210,6 +210,7 @@ type Playlist struct { CreatedAt time.Time `json:"created"` UpdatedAt time.Time `json:"updated"` Description string `json:"description"` + PlayoutMode string `json:"playout-mode" gorm:"not null;default:'linear'"` ShowName string `json:"show" gorm:"not null;index"` Show Show `json:"-" gorm:"association_foreignkey:Name"` Entries []PlaylistEntry `json:"entries,omitempty"`