Files
minstrel/internal/sync/types.go
T
bvandeusenandClaude Opus 5.5 285a24f0ab
release / web (push) Successful in 1m13s
release / go (push) Successful in 1m48s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 3m56s
release / android (push) Successful in 4m19s
release / Build signed APK (push) Successful in 4m40s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
feat(db): fold every migration into one baseline at version 106
0106_baseline.up.sql is the schema at version 106 and the settings rows
it starts with, taken from a database migrated through 0001–0106; a
database built from the baseline alone dumps identically. A database
already at 106 skips it. Comments that pointed at a migration number now
name the table or constraint instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 00:57:18 -05:00

41 lines
1.4 KiB
Go

// Package sync supports the delta-sync endpoint by writing an
// append-only library_changes log alongside every mutation on tracked
// entities (artists, albums, tracks, likes, playlists, playlist_tracks).
//
// Callers MUST pass the same transaction that performed the underlying
// mutation — the change row and the mutation must commit or roll back
// together. See LogChange in changes.go.
package sync
// EntityType enumerates the entity kinds whose mutations are tracked
// by the library_changes log. Values must stay in sync with the CHECK
// constraint on library_changes.entity_type.
type EntityType string
const (
EntityArtist EntityType = "artist"
EntityAlbum EntityType = "album"
EntityTrack EntityType = "track"
EntityLikeTrack EntityType = "like_track"
EntityLikeAlbum EntityType = "like_album"
EntityLikeArtist EntityType = "like_artist"
EntityPlaylist EntityType = "playlist"
EntityPlaylistTrack EntityType = "playlist_track"
)
// Op is upsert or delete. Matches the CHECK constraint on library_changes.op.
type Op string
const (
OpUpsert Op = "upsert"
OpDelete Op = "delete"
)
// Change is the wire shape returned by the sync endpoint to clients.
type Change struct {
ID int64 `json:"id"`
EntityType EntityType `json:"entity_type"`
EntityID string `json:"entity_id"`
Op Op `json:"op"`
}