Database basic CRUD (#27)

* started schema

* db schemas beginning

* first db schema gen

* added sqlc generation with go generate and sqlite driver

* i think these dependencies are needed

* added IF NOT EXISTS to create and CRUD for each table

* fixed missing columns

* added missing field

* fixed code generation with sqlc
This commit is contained in:
2025-04-16 13:45:44 -05:00
committed by GitHub
parent d062644a3e
commit b24e734ae3
36 changed files with 979 additions and 5 deletions
@@ -0,0 +1,17 @@
-- name: CreateArtistCredit :one
INSERT INTO artist_credit (text) VALUES (?)
RETURNING *;
-- name: GetArtistCredit :one
SELECT * FROM artist_credit
WHERE id = ? LIMIT 1;
-- name: UpdateArtistCredit :exec
UPDATE artist_credit
SET text = ?
WHERE id =?;
-- name: DeleteArtistCredit :exec
DELETE FROM artist_credit
WHERE id =?;
@@ -0,0 +1,17 @@
-- name: CreateArtistCreditArtist :one
INSERT INTO artist_credit_artist (artist_id, credit_id) VALUES (?, ?)
RETURNING *;
-- name: GetArtistCreditArtist :one
SELECT * FROM artist_credit_artist
WHERE id = ? LIMIT 1;
-- name: UpdateArtistCreditArtist :exec
UPDATE artist_credit_artist
SET artist_id = ?, credit_id = ?
WHERE id =?;
-- name: DeleteArtistCreditArtist :exec
DELETE FROM artist_credit_artist
WHERE id =?;
+17
View File
@@ -0,0 +1,17 @@
-- name: CreateArtist :one
INSERT INTO artists (name) VALUES (?)
RETURNING *;
-- name: GetArtist :one
SELECT * FROM artists
WHERE id = ? LIMIT 1;
-- name: UpdateArtist :exec
UPDATE artists
SET name = ?
WHERE id =?;
-- name: DeleteArtist :exec
DELETE FROM artists
WHERE id =?;
@@ -0,0 +1,17 @@
-- name: CreateAudioFile :one
INSERT INTO audio_files (file_path, length_milliseconds, file_type_id, recording_id) VALUES (?, ?, ?, ?)
RETURNING *;
-- name: GetAudioFile :one
SELECT * FROM audio_files
WHERE id = ? LIMIT 1;
-- name: UpdateAudioFile :exec
UPDATE audio_files
SET file_path = ?, length_milliseconds = ?, file_type_id = ?, recording_id = ?
WHERE id =?;
-- name: DeleteAudioFile :exec
DELETE FROM audio_files
WHERE id =?;
@@ -0,0 +1,17 @@
-- name: CreateCoverArt :one
INSERT INTO cover_art (is_embedded, file_path, file_type_id) VALUES (?, ?, ?)
RETURNING *;
-- name: GetCoverArt :one
SELECT * FROM cover_art
WHERE id = ? LIMIT 1;
-- name: UpdateCoverArt :exec
UPDATE cover_art
SET is_embedded = ?, file_path = ?, file_type_id = ?
WHERE id =?;
-- name: DeleteCoverArt :exec
DELETE FROM cover_art
WHERE id =?;
@@ -0,0 +1,17 @@
-- name: CreateFileType :one
INSERT INTO file_types (extension) VALUES (?)
RETURNING *;
-- name: GetFileType :one
SELECT * FROM file_types
WHERE id = ? LIMIT 1;
-- name: UpdateFileType :exec
UPDATE file_types
SET extension = ?
WHERE id =?;
-- name: DeleteFileType :exec
DELETE FROM file_types
WHERE id =?;
@@ -0,0 +1,17 @@
-- name: CreateRecording :one
INSERT INTO recordings (name) VALUES (?)
RETURNING *;
-- name: GetRecording :one
SELECT * FROM recordings
WHERE id = ? LIMIT 1;
-- name: UpdateRecording :exec
UPDATE recordings
SET name = ?
WHERE id =?;
-- name: DeleteRecording :exec
DELETE FROM recordings
WHERE id =?;
@@ -0,0 +1,17 @@
-- name: CreateReleaseGroupRecording :one
INSERT INTO release_group_recordings (release_group_id, recording_id) VALUES (?,?)
RETURNING *;
-- name: GetReleaseGroupRecording :one
SELECT * FROM release_group_recordings
WHERE id = ? LIMIT 1;
-- name: UpdateReleaseGroupRecording :exec
UPDATE release_group_recordings
SET release_group_id = ?, recording_id = ?
WHERE id =?;
-- name: DeleteReleaseGroupRecording :exec
DELETE FROM release_group_recordings
WHERE id =?;
@@ -0,0 +1,17 @@
-- name: CreateReleaseGroup :one
INSERT INTO release_groups (name) VALUES (?)
RETURNING *;
-- name: GetReleaseGroup :one
SELECT * FROM release_groups
WHERE id = ? LIMIT 1;
-- name: UpdateReleaseGroup :exec
UPDATE release_groups
SET name = ?
WHERE id =?;
-- name: DeleteReleaseGroup :exec
DELETE FROM release_groups
WHERE id =?;