곡 합치기: 멜론 id가 없는 곡으로 합칠 때 UNIQUE 오류로 실패하던 것 수정(복사본에서 빼고 남는 곡으로 옮김). fix-text 중복 합치기가 운영에서 이걸로 막혔음(트랜잭션이라 바뀐 것 없음)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -134,7 +134,13 @@ export function mergeSongs(db: Database, target: number, others: number[], now =
|
||||
FROM (SELECT youtube_id, youtube_status, youtube_source, youtube_channel, youtube_title, embeddable FROM songs WHERE id = ?) o
|
||||
WHERE songs.id = ? AND songs.youtube_status <> 'matched' AND o.youtube_status = 'matched'`,
|
||||
).run(o, target);
|
||||
db.query('UPDATE songs SET year = COALESCE(year, (SELECT year FROM songs WHERE id = ?)), melon_id = COALESCE(melon_id, (SELECT melon_id FROM songs x WHERE x.id = ? AND NOT EXISTS (SELECT 1 FROM songs y WHERE y.melon_id = x.melon_id AND y.id <> x.id))) WHERE id = ?').run(o, o, target);
|
||||
db.query('UPDATE songs SET year = COALESCE(year, (SELECT year FROM songs WHERE id = ?)) WHERE id = ?').run(o, target);
|
||||
// The Melon id moves over (it is unique, and later imports find the song by it): off the copy first, then onto the target.
|
||||
const mid = db.query<{ melon_id: number | null }, [number]>('SELECT melon_id FROM songs WHERE id = ?').get(o)?.melon_id ?? null;
|
||||
if (mid !== null && db.query<{ m: number | null }, [number]>('SELECT melon_id m FROM songs WHERE id = ?').get(target)?.m === null) {
|
||||
db.query('UPDATE songs SET melon_id = NULL WHERE id = ?').run(o);
|
||||
db.query('UPDATE songs SET melon_id = ? WHERE id = ?').run(mid, target);
|
||||
}
|
||||
}
|
||||
trashSongs(db, rest, now);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user