feat(server/m7-379): heal existing artist+album mbid on rescan
This commit is contained in:
@@ -515,6 +515,25 @@ func (q *Queries) SearchAlbums(ctx context.Context, arg SearchAlbumsParams) ([]A
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setAlbumMbidIfNull = `-- name: SetAlbumMbidIfNull :exec
|
||||
UPDATE albums
|
||||
SET mbid = $2,
|
||||
updated_at = now()
|
||||
WHERE id = $1 AND mbid IS NULL
|
||||
`
|
||||
|
||||
type SetAlbumMbidIfNullParams struct {
|
||||
ID pgtype.UUID
|
||||
Mbid *string
|
||||
}
|
||||
|
||||
// M7 #379: heal MBID on existing album rows during rescan. Idempotent —
|
||||
// only updates when the existing mbid is NULL.
|
||||
func (q *Queries) SetAlbumMbidIfNull(ctx context.Context, arg SetAlbumMbidIfNullParams) error {
|
||||
_, err := q.db.Exec(ctx, setAlbumMbidIfNull, arg.ID, arg.Mbid)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertAlbum = `-- name: UpsertAlbum :one
|
||||
INSERT INTO albums (title, sort_title, artist_id, release_date, mbid, cover_art_path)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
|
||||
Reference in New Issue
Block a user