🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
fix(db): check both name and target_format in default transcodings migration (#5175)
Deluan Quintãod0fbba14ff7d
diff --git a/db/migrations/20260309203355_ensure_default_transcodings.go b/db/migrations/20260309203355_ensure_default_transcodings.goindex ff3838222..ab6d24952 100644--- a/db/migrations/20260309203355_ensure_default_transcodings.go+++ b/db/migrations/20260309203355_ensure_default_transcodings.go@@ -17,9 +17,12 @@ func upEnsureDefaultTranscodings(_ context.Context, tx *sql.Tx) error {// Older installations may be missing default transcodings that were added// after the initial seeding (e.g., aac was added later than mp3/opus).// Insert any missing defaults without touching user-customized entries.+ // Check both target_format and name since both have UNIQUE constraints,+ // and older entries may have a different target_format (e.g., 'oga' vs 'opus')+ // but the same name.for _, t := range consts.DefaultTranscodings {var count int- err := tx.QueryRow("SELECT COUNT(*) FROM transcoding WHERE target_format = ?", t.TargetFormat).Scan(&count)+ err := tx.QueryRow("SELECT COUNT(*) FROM transcoding WHERE target_format = ? OR name = ?", t.TargetFormat, t.Name).Scan(&count)if err != nil {return err}