mirror of
https://github.com/navidrome/navidrome.git
synced 2026-04-03 06:41:01 +00:00
feat(playlist): add migration for playlist image field rename and external URL
This commit is contained in:
parent
c4fd8e3125
commit
169d3b8d72
30
db/migrations/20260302021413_rename_playlist_image_fields.go
Normal file
30
db/migrations/20260302021413_rename_playlist_image_fields.go
Normal file
@ -0,0 +1,30 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/pressly/goose/v3"
|
||||
)
|
||||
|
||||
func init() {
|
||||
goose.AddMigrationContext(upRenamePlaylistImageFields, downRenamePlaylistImageFields)
|
||||
}
|
||||
|
||||
func upRenamePlaylistImageFields(ctx context.Context, tx *sql.Tx) error {
|
||||
_, err := tx.ExecContext(ctx, `ALTER TABLE playlist RENAME COLUMN image_file TO uploaded_image;`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `ALTER TABLE playlist ADD COLUMN external_image_url VARCHAR(255) DEFAULT '';`)
|
||||
return err
|
||||
}
|
||||
|
||||
func downRenamePlaylistImageFields(ctx context.Context, tx *sql.Tx) error {
|
||||
_, err := tx.ExecContext(ctx, `ALTER TABLE playlist DROP COLUMN external_image_url;`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `ALTER TABLE playlist RENAME COLUMN uploaded_image TO image_file;`)
|
||||
return err
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user