-- name: ClearSongs :exec
DELETE FROM song;

-- name: ClearSongsByGameId :exec
DELETE FROM song WHERE game_id = $1;

-- name: AddSong :exec
INSERT INTO song(game_id, song_name, path, file_name, hash) VALUES ($1, $2, $3, $4, $5);

-- name: CheckSong :one
SELECT COUNT(*) FROM song WHERE path = $1;

-- name: CheckSongWithHash :one
SELECT COUNT(*) FROM song WHERE hash = $1;

-- name: GetSongWithHash :one
SELECT * FROM song WHERE hash = $1;

-- name: UpdateSong :exec
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;

-- name: FindSongsFromGame :many
SELECT *
FROM song
WHERE game_id = $1;

-- name: AddSongPlayed :exec
UPDATE song SET times_played = times_played + 1
WHERE game_id = $1 AND song_name = $2;

-- name: FetchAllSongs :many
SELECT * FROM song;

-- name: RemoveBrokenSong :exec
DELETE FROM song WHERE path = $1;

-- name: RemoveBrokenSongs :exec
DELETE FROM song where path = any (sqlc.slice('paths'));
