add crud for custom transcode selection profile

This commit is contained in:
sentriz
2020-03-11 18:40:04 +00:00
parent c475a9d042
commit 55bdc2884b
8 changed files with 495 additions and 299 deletions

View File

@@ -40,6 +40,7 @@ func New(path string) (*DB, error) {
&migrationInitSchema,
&migrationCreateInitUser,
&migrationMergePlaylist,
&migrationCreateTranscode,
&migrationAddGenre,
})
if err = migr.Migrate(); err != nil {

View File

@@ -6,6 +6,8 @@ import (
"gopkg.in/gormigrate.v1"
)
// $ date '+%Y%m%d%H%M'
// not really a migration
var migrationInitSchema = gormigrate.Migration{
ID: "202002192100",
@@ -68,8 +70,18 @@ var migrationMergePlaylist = gormigrate.Migration{
},
}
var migrationCreateTranscode = gormigrate.Migration{
ID: "202003111222",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(
TranscodePreference{},
).
Error
},
}
var migrationAddGenre = gormigrate.Migration{
ID: "202003020000",
ID: "202003121330",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(
Genre{},

View File

@@ -189,3 +189,10 @@ func (p *PlayQueue) GetItems() []int {
func (p *PlayQueue) SetItems(items []int) {
p.Items = joinInt(items, ",")
}
type TranscodePreference struct {
User *User
UserID int `sql:"default: null; type:int REFERENCES users(id) ON DELETE CASCADE"`
Client string `gorm:"not null; unique_index:idx_client_profile" sql:"default: null"`
Profile string `gorm:"not null; unique_index:idx_client_profile" sql:"default: null"`
}