feat: Add id column to song table and prep for UUID migration

- Add id serial4 PK to song table (was composite PK)
- Update queries to use soundtrack_id + path
- Add UUID columns to soundtrack and song (nullable)
- Add migration tracking table

TODO: Run sqlc generate, then create backfill migration (000008)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-06-01 21:58:21 +02:00
parent 176848bb6d
commit b0418b4f38
8 changed files with 174 additions and 50 deletions
+7 -4
View File
@@ -8,7 +8,7 @@ DELETE FROM song WHERE soundtrack_id = $1;
INSERT INTO song(soundtrack_id, song_name, path, file_name, hash) VALUES ($1, $2, $3, $4, $5);
-- name: CheckSong :one
SELECT COUNT(*) FROM song WHERE path = $1;
SELECT COUNT(*) FROM song WHERE soundtrack_id = $1 AND path = $2;
-- name: CheckSongWithHash :one
SELECT COUNT(*) FROM song WHERE hash = $1;
@@ -20,7 +20,7 @@ SELECT * FROM song WHERE hash = $1;
UPDATE song SET song_name=$1, file_name=$2, path=$3 where hash=$4;
-- name: AddHashToSong :exec
UPDATE song SET hash=$1 where path=$2;
UPDATE song SET hash=$1 where soundtrack_id = $2 AND path = $3;
-- name: FindSongsFromSoundtrack :many
SELECT *
@@ -34,8 +34,11 @@ WHERE soundtrack_id = $1 AND song_name = $2;
-- name: FetchAllSongs :many
SELECT * FROM song;
-- name: GetSongById :one
SELECT * FROM song WHERE id = $1;
-- name: RemoveBrokenSong :exec
DELETE FROM song WHERE path = $1;
DELETE FROM song WHERE soundtrack_id = $1 AND path = $2;
-- name: RemoveBrokenSongs :exec
DELETE FROM song where path = any (sqlc.slice('paths'));
DELETE FROM song WHERE id = ANY($1);