add crud for custom transcode selection profile
This commit is contained in:
1
db/db.go
1
db/db.go
@@ -40,6 +40,7 @@ func New(path string) (*DB, error) {
|
||||
&migrationInitSchema,
|
||||
&migrationCreateInitUser,
|
||||
&migrationMergePlaylist,
|
||||
&migrationCreateTranscode,
|
||||
})
|
||||
if err = migr.Migrate(); err != nil {
|
||||
return nil, errors.Wrap(err, "migrating to latest version")
|
||||
|
||||
@@ -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",
|
||||
@@ -67,3 +69,13 @@ var migrationMergePlaylist = gormigrate.Migration{
|
||||
Error
|
||||
},
|
||||
}
|
||||
|
||||
var migrationCreateTranscode = gormigrate.Migration{
|
||||
ID: "202003111222",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return tx.AutoMigrate(
|
||||
TranscodePreference{},
|
||||
).
|
||||
Error
|
||||
},
|
||||
}
|
||||
|
||||
@@ -176,3 +176,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"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user