From 65790430b3ced0fb05e9c2483f4724612f130a7f Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 19 Jun 2026 15:33:17 -0400 Subject: [PATCH] fix(lyrics): preserve [] (not null) for empty lyrics in backfill migration ParseLyrics returns nil for zero-line input (whitespace-only stored lyrics). json.Marshal(nil LyricList) produces null, violating the DB invariant that media_file.lyrics uses [] for empty lyrics, never null. Initialize to model.LyricList{} when ParseLyrics returns nil so the marshalled result is always []. --- db/migrations/20231209211223_alter_lyric_column.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/migrations/20231209211223_alter_lyric_column.go b/db/migrations/20231209211223_alter_lyric_column.go index 259a37745..9afc3f2c9 100644 --- a/db/migrations/20231209211223_alter_lyric_column.go +++ b/db/migrations/20231209211223_alter_lyric_column.go @@ -50,6 +50,10 @@ func upAlterLyricColumn(ctx context.Context, tx *sql.Tx) error { if err != nil { return err } + if parsed == nil { + // Preserve the column invariant: empty lyrics serialize to [], never null + parsed = model.LyricList{} + } text, err := json.Marshal(parsed) if err != nil {