feat: Rename game to soundtrack throughout codebase

- Database migration: rename game table to soundtrack
- Rename game_name to soundtrack_name, game_id to soundtrack_id
- Update all SQL queries in soundtrack.sql, song.sql, song_list.sql, statistics.sql
- Regenerate sqlc code (soundtrack.sql.go, song.sql.go, etc.)
- Update backend: music.go, sync.go, statistics.go
- Update server: musicHandler.go, syncHandler.go, routes.go
- Update frontend: hello.go
- Keep URL paths as /games for backward compatibility

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-06-01 20:23:05 +02:00
parent c60f40d7e3
commit cec408187d
20 changed files with 760 additions and 694 deletions
+246
View File
@@ -0,0 +1,246 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: soundtrack.sql
package repository
import (
"context"
)
const addSoundtrackPlayed = `-- name: AddSoundtrackPlayed :exec
UPDATE soundtrack SET times_played = times_played + 1, last_played = now() WHERE id = $1
`
func (q *Queries) AddSoundtrackPlayed(ctx context.Context, id int32) error {
_, err := q.db.Exec(ctx, addSoundtrackPlayed, id)
return err
}
const clearSoundtracks = `-- name: ClearSoundtracks :exec
DELETE FROM soundtrack
`
func (q *Queries) ClearSoundtracks(ctx context.Context) error {
_, err := q.db.Exec(ctx, clearSoundtracks)
return err
}
const findAllSoundtracks = `-- name: FindAllSoundtracks :many
SELECT id, soundtrack_name, added, deleted, last_changed, path, times_played, last_played, number_of_songs, hash
FROM soundtrack
WHERE deleted IS NULL
ORDER BY soundtrack_name
`
func (q *Queries) FindAllSoundtracks(ctx context.Context) ([]Soundtrack, error) {
rows, err := q.db.Query(ctx, findAllSoundtracks)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Soundtrack
for rows.Next() {
var i Soundtrack
if err := rows.Scan(
&i.ID,
&i.SoundtrackName,
&i.Added,
&i.Deleted,
&i.LastChanged,
&i.Path,
&i.TimesPlayed,
&i.LastPlayed,
&i.NumberOfSongs,
&i.Hash,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getAllSoundtracksIncludingDeleted = `-- name: GetAllSoundtracksIncludingDeleted :many
SELECT id, soundtrack_name, added, deleted, last_changed, path, times_played, last_played, number_of_songs, hash
FROM soundtrack
ORDER BY soundtrack_name
`
func (q *Queries) GetAllSoundtracksIncludingDeleted(ctx context.Context) ([]Soundtrack, error) {
rows, err := q.db.Query(ctx, getAllSoundtracksIncludingDeleted)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Soundtrack
for rows.Next() {
var i Soundtrack
if err := rows.Scan(
&i.ID,
&i.SoundtrackName,
&i.Added,
&i.Deleted,
&i.LastChanged,
&i.Path,
&i.TimesPlayed,
&i.LastPlayed,
&i.NumberOfSongs,
&i.Hash,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getIdBySoundtrackName = `-- name: GetIdBySoundtrackName :one
SELECT id FROM soundtrack WHERE soundtrack_name = $1
`
func (q *Queries) GetIdBySoundtrackName(ctx context.Context, soundtrackName string) (int32, error) {
row := q.db.QueryRow(ctx, getIdBySoundtrackName, soundtrackName)
var id int32
err := row.Scan(&id)
return id, err
}
const getSoundtrackById = `-- name: GetSoundtrackById :one
SELECT id, soundtrack_name, added, deleted, last_changed, path, times_played, last_played, number_of_songs, hash
FROM soundtrack
WHERE id = $1
AND deleted IS NULL
`
func (q *Queries) GetSoundtrackById(ctx context.Context, id int32) (Soundtrack, error) {
row := q.db.QueryRow(ctx, getSoundtrackById, id)
var i Soundtrack
err := row.Scan(
&i.ID,
&i.SoundtrackName,
&i.Added,
&i.Deleted,
&i.LastChanged,
&i.Path,
&i.TimesPlayed,
&i.LastPlayed,
&i.NumberOfSongs,
&i.Hash,
)
return i, err
}
const getSoundtrackNameById = `-- name: GetSoundtrackNameById :one
SELECT soundtrack_name FROM soundtrack WHERE id = $1
`
func (q *Queries) GetSoundtrackNameById(ctx context.Context, id int32) (string, error) {
row := q.db.QueryRow(ctx, getSoundtrackNameById, id)
var soundtrack_name string
err := row.Scan(&soundtrack_name)
return soundtrack_name, err
}
const insertSoundtrack = `-- name: InsertSoundtrack :one
INSERT INTO soundtrack (soundtrack_name, path, hash, added) VALUES ($1, $2, $3, now()) returning id
`
type InsertSoundtrackParams struct {
SoundtrackName string `json:"soundtrack_name"`
Path string `json:"path"`
Hash string `json:"hash"`
}
func (q *Queries) InsertSoundtrack(ctx context.Context, arg InsertSoundtrackParams) (int32, error) {
row := q.db.QueryRow(ctx, insertSoundtrack, arg.SoundtrackName, arg.Path, arg.Hash)
var id int32
err := row.Scan(&id)
return id, err
}
const insertSoundtrackWithExistingId = `-- name: InsertSoundtrackWithExistingId :exec
INSERT INTO soundtrack (id, soundtrack_name, path, hash, added) VALUES ($1, $2, $3, $4, now())
`
type InsertSoundtrackWithExistingIdParams struct {
ID int32 `json:"id"`
SoundtrackName string `json:"soundtrack_name"`
Path string `json:"path"`
Hash string `json:"hash"`
}
func (q *Queries) InsertSoundtrackWithExistingId(ctx context.Context, arg InsertSoundtrackWithExistingIdParams) error {
_, err := q.db.Exec(ctx, insertSoundtrackWithExistingId,
arg.ID,
arg.SoundtrackName,
arg.Path,
arg.Hash,
)
return err
}
const removeSoundtrackDeletionDate = `-- name: RemoveSoundtrackDeletionDate :exec
UPDATE soundtrack SET deleted=NULL WHERE id=$1
`
func (q *Queries) RemoveSoundtrackDeletionDate(ctx context.Context, id int32) error {
_, err := q.db.Exec(ctx, removeSoundtrackDeletionDate, id)
return err
}
const resetSoundtrackIdSeq = `-- name: ResetSoundtrackIdSeq :one
SELECT setval('soundtrack_id_seq', (SELECT MAX(id) FROM soundtrack)+1)
`
func (q *Queries) ResetSoundtrackIdSeq(ctx context.Context) (int64, error) {
row := q.db.QueryRow(ctx, resetSoundtrackIdSeq)
var setval int64
err := row.Scan(&setval)
return setval, err
}
const setSoundtrackDeletionDate = `-- name: SetSoundtrackDeletionDate :exec
UPDATE soundtrack SET deleted=now() WHERE deleted IS NULL
`
func (q *Queries) SetSoundtrackDeletionDate(ctx context.Context) error {
_, err := q.db.Exec(ctx, setSoundtrackDeletionDate)
return err
}
const updateSoundtrackHash = `-- name: UpdateSoundtrackHash :exec
UPDATE soundtrack SET hash=$1, last_changed=now() WHERE id=$2
`
type UpdateSoundtrackHashParams struct {
Hash string `json:"hash"`
ID int32 `json:"id"`
}
func (q *Queries) UpdateSoundtrackHash(ctx context.Context, arg UpdateSoundtrackHashParams) error {
_, err := q.db.Exec(ctx, updateSoundtrackHash, arg.Hash, arg.ID)
return err
}
const updateSoundtrackName = `-- name: UpdateSoundtrackName :exec
UPDATE soundtrack SET soundtrack_name=$1, path=$2, last_changed=now() WHERE id=$3
`
type UpdateSoundtrackNameParams struct {
Name string `json:"name"`
Path string `json:"path"`
ID int32 `json:"id"`
}
func (q *Queries) UpdateSoundtrackName(ctx context.Context, arg UpdateSoundtrackNameParams) error {
_, err := q.db.Exec(ctx, updateSoundtrackName, arg.Name, arg.Path, arg.ID)
return err
}