feat(server): library_changes log table + sqlc queries
Append-only change log for library entities. Every mutation on artists/albums/tracks/likes/playlists/playlist_tracks will write a row in the same transaction as the mutation itself (wired in subsequent commits). Powers the Flutter delta-sync endpoint (#357). - 0025_library_changes migration (up + down) - internal/db/queries/library_changes.sql (Insert, GetSince, MaxCursor, MinCursor) - regenerated dbq from sqlc Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
-- name: InsertLibraryChange :exec
|
||||
INSERT INTO library_changes (entity_type, entity_id, op)
|
||||
VALUES ($1, $2, $3);
|
||||
|
||||
-- name: GetLibraryChangesSince :many
|
||||
SELECT id, entity_type, entity_id, op, changed_at
|
||||
FROM library_changes
|
||||
WHERE id > $1
|
||||
ORDER BY id ASC
|
||||
LIMIT $2;
|
||||
|
||||
-- name: GetMaxLibraryChangeCursor :one
|
||||
SELECT COALESCE(MAX(id), 0)::BIGINT FROM library_changes;
|
||||
|
||||
-- name: GetMinLibraryChangeCursor :one
|
||||
SELECT COALESCE(MIN(id), 0)::BIGINT FROM library_changes;
|
||||
Reference in New Issue
Block a user