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
+1
View File
@@ -2,3 +2,4 @@ frontend/dist
node_modules
build
test_data
test.db
+21 -3
View File
@@ -1,7 +1,25 @@
package database
type DB struct{}
import (
"database/sql"
"fmt"
func NewDB() (*DB, error) {
return &DB{}, nil
_ "modernc.org/sqlite"
)
//go:generate sqlc vet
//go:generate sqlc generate
type DB struct{
db *sql.DB
}
func NewDB(sqliteDBFilePath string) (*DB, error) {
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
return nil, fmt.Errorf("could not connect to sqlite database: %w", err)
}
return &DB{
db: db,
}, nil
}
@@ -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 =?;
@@ -0,0 +1,4 @@
CREATE TABLE IF NOT EXISTS artist_credit (
id int PRIMARY KEY,
text string NOT NULL
);
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS artist_credit_artist (
id int PRIMARY KEY,
artist_id int NOT NULL,
credit_id int NOT NULL,
FOREIGN KEY(artist_id) REFERENCES artists(id),
FOREIGN KEY(credit_id) REFERENCES artist_credit(id)
);
+4
View File
@@ -0,0 +1,4 @@
CREATE TABLE IF NOT EXISTS artists (
id int PRIMARY KEY,
name text NOT NULL
);
@@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS audio_files (
id int PRIMARY KEY,
file_path text NOT NULL UNIQUE,
length_milliseconds int NOT NULL,
file_type_id int NOT NULL,
recording_id int NOT NULL,
FOREIGN KEY(file_type_id) REFERENCES file_types(id),
FOREIGN KEY(recording_id) REFERENCES recordings(id)
);
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS cover_art (
id int PRIMARY KEY,
is_embedded bool NOT NULL DEFAULT(false),
file_path text NOT NULL,
file_type_id int NOT NULL,
FOREIGN KEY(file_type_id) REFERENCES file_types(id)
);
@@ -0,0 +1,4 @@
CREATE TABLE IF NOT EXISTS file_types (
id INTEGER PRIMARY KEY,
extension text NOT NULL UNIQUE
);
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS recordings (
id int PRIMARY KEY,
name text NOT NULL,
artist_credit_id int NOT NULL,
FOREIGN KEY(artist_credit_id) REFERENCES artist_credit(id)
);
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS release_group_recordings (
id int PRIMARY KEY,
release_group_id int NOT NULL,
recording_id int NOT NULL,
FOREIGN KEY(release_group_id) REFERENCES release_groups(id),
FOREIGN KEY(recording_id) REFERENCES recordings(id)
);
@@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS release_groups (
id int PRIMARY KEY,
name text NOT NULL,
cover_art_id int NOT NULL,
FOREIGN KEY(cover_art_id) REFERENCES cover_art(id)
);
@@ -0,0 +1,60 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: artist_credit.sql
package sqlcgen
import (
"context"
)
const createArtistCredit = `-- name: CreateArtistCredit :one
INSERT INTO artist_credit (text) VALUES (?)
RETURNING id, text
`
func (q *Queries) CreateArtistCredit(ctx context.Context, text interface{}) (ArtistCredit, error) {
row := q.db.QueryRowContext(ctx, createArtistCredit, text)
var i ArtistCredit
err := row.Scan(&i.ID, &i.Text)
return i, err
}
const deleteArtistCredit = `-- name: DeleteArtistCredit :exec
DELETE FROM artist_credit
WHERE id =?
`
func (q *Queries) DeleteArtistCredit(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteArtistCredit, id)
return err
}
const getArtistCredit = `-- name: GetArtistCredit :one
SELECT id, text FROM artist_credit
WHERE id = ? LIMIT 1
`
func (q *Queries) GetArtistCredit(ctx context.Context, id int64) (ArtistCredit, error) {
row := q.db.QueryRowContext(ctx, getArtistCredit, id)
var i ArtistCredit
err := row.Scan(&i.ID, &i.Text)
return i, err
}
const updateArtistCredit = `-- name: UpdateArtistCredit :exec
UPDATE artist_credit
SET text = ?
WHERE id =?
`
type UpdateArtistCreditParams struct {
Text interface{}
ID int64
}
func (q *Queries) UpdateArtistCredit(ctx context.Context, arg UpdateArtistCreditParams) error {
_, err := q.db.ExecContext(ctx, updateArtistCredit, arg.Text, arg.ID)
return err
}
@@ -0,0 +1,66 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: artist_credit_artists.sql
package sqlcgen
import (
"context"
)
const createArtistCreditArtist = `-- name: CreateArtistCreditArtist :one
INSERT INTO artist_credit_artist (artist_id, credit_id) VALUES (?, ?)
RETURNING id, artist_id, credit_id
`
type CreateArtistCreditArtistParams struct {
ArtistID int64
CreditID int64
}
func (q *Queries) CreateArtistCreditArtist(ctx context.Context, arg CreateArtistCreditArtistParams) (ArtistCreditArtist, error) {
row := q.db.QueryRowContext(ctx, createArtistCreditArtist, arg.ArtistID, arg.CreditID)
var i ArtistCreditArtist
err := row.Scan(&i.ID, &i.ArtistID, &i.CreditID)
return i, err
}
const deleteArtistCreditArtist = `-- name: DeleteArtistCreditArtist :exec
DELETE FROM artist_credit_artist
WHERE id =?
`
func (q *Queries) DeleteArtistCreditArtist(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteArtistCreditArtist, id)
return err
}
const getArtistCreditArtist = `-- name: GetArtistCreditArtist :one
SELECT id, artist_id, credit_id FROM artist_credit_artist
WHERE id = ? LIMIT 1
`
func (q *Queries) GetArtistCreditArtist(ctx context.Context, id int64) (ArtistCreditArtist, error) {
row := q.db.QueryRowContext(ctx, getArtistCreditArtist, id)
var i ArtistCreditArtist
err := row.Scan(&i.ID, &i.ArtistID, &i.CreditID)
return i, err
}
const updateArtistCreditArtist = `-- name: UpdateArtistCreditArtist :exec
UPDATE artist_credit_artist
SET artist_id = ?, credit_id = ?
WHERE id =?
`
type UpdateArtistCreditArtistParams struct {
ArtistID int64
CreditID int64
ID int64
}
func (q *Queries) UpdateArtistCreditArtist(ctx context.Context, arg UpdateArtistCreditArtistParams) error {
_, err := q.db.ExecContext(ctx, updateArtistCreditArtist, arg.ArtistID, arg.CreditID, arg.ID)
return err
}
@@ -0,0 +1,60 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: artists.sql
package sqlcgen
import (
"context"
)
const createArtist = `-- name: CreateArtist :one
INSERT INTO artists (name) VALUES (?)
RETURNING id, name
`
func (q *Queries) CreateArtist(ctx context.Context, name string) (Artist, error) {
row := q.db.QueryRowContext(ctx, createArtist, name)
var i Artist
err := row.Scan(&i.ID, &i.Name)
return i, err
}
const deleteArtist = `-- name: DeleteArtist :exec
DELETE FROM artists
WHERE id =?
`
func (q *Queries) DeleteArtist(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteArtist, id)
return err
}
const getArtist = `-- name: GetArtist :one
SELECT id, name FROM artists
WHERE id = ? LIMIT 1
`
func (q *Queries) GetArtist(ctx context.Context, id int64) (Artist, error) {
row := q.db.QueryRowContext(ctx, getArtist, id)
var i Artist
err := row.Scan(&i.ID, &i.Name)
return i, err
}
const updateArtist = `-- name: UpdateArtist :exec
UPDATE artists
SET name = ?
WHERE id =?
`
type UpdateArtistParams struct {
Name string
ID int64
}
func (q *Queries) UpdateArtist(ctx context.Context, arg UpdateArtistParams) error {
_, err := q.db.ExecContext(ctx, updateArtist, arg.Name, arg.ID)
return err
}
@@ -0,0 +1,93 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: audio_files.sql
package sqlcgen
import (
"context"
)
const createAudioFile = `-- name: CreateAudioFile :one
INSERT INTO audio_files (file_path, length_milliseconds, file_type_id, recording_id) VALUES (?, ?, ?, ?)
RETURNING id, file_path, length_milliseconds, file_type_id, recording_id
`
type CreateAudioFileParams struct {
FilePath string
LengthMilliseconds int64
FileTypeID int64
RecordingID int64
}
func (q *Queries) CreateAudioFile(ctx context.Context, arg CreateAudioFileParams) (AudioFile, error) {
row := q.db.QueryRowContext(ctx, createAudioFile,
arg.FilePath,
arg.LengthMilliseconds,
arg.FileTypeID,
arg.RecordingID,
)
var i AudioFile
err := row.Scan(
&i.ID,
&i.FilePath,
&i.LengthMilliseconds,
&i.FileTypeID,
&i.RecordingID,
)
return i, err
}
const deleteAudioFile = `-- name: DeleteAudioFile :exec
DELETE FROM audio_files
WHERE id =?
`
func (q *Queries) DeleteAudioFile(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteAudioFile, id)
return err
}
const getAudioFile = `-- name: GetAudioFile :one
SELECT id, file_path, length_milliseconds, file_type_id, recording_id FROM audio_files
WHERE id = ? LIMIT 1
`
func (q *Queries) GetAudioFile(ctx context.Context, id int64) (AudioFile, error) {
row := q.db.QueryRowContext(ctx, getAudioFile, id)
var i AudioFile
err := row.Scan(
&i.ID,
&i.FilePath,
&i.LengthMilliseconds,
&i.FileTypeID,
&i.RecordingID,
)
return i, err
}
const updateAudioFile = `-- name: UpdateAudioFile :exec
UPDATE audio_files
SET file_path = ?, length_milliseconds = ?, file_type_id = ?, recording_id = ?
WHERE id =?
`
type UpdateAudioFileParams struct {
FilePath string
LengthMilliseconds int64
FileTypeID int64
RecordingID int64
ID int64
}
func (q *Queries) UpdateAudioFile(ctx context.Context, arg UpdateAudioFileParams) error {
_, err := q.db.ExecContext(ctx, updateAudioFile,
arg.FilePath,
arg.LengthMilliseconds,
arg.FileTypeID,
arg.RecordingID,
arg.ID,
)
return err
}
@@ -0,0 +1,83 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: cover_art.sql
package sqlcgen
import (
"context"
)
const createCoverArt = `-- name: CreateCoverArt :one
INSERT INTO cover_art (is_embedded, file_path, file_type_id) VALUES (?, ?, ?)
RETURNING id, is_embedded, file_path, file_type_id
`
type CreateCoverArtParams struct {
IsEmbedded bool
FilePath string
FileTypeID int64
}
func (q *Queries) CreateCoverArt(ctx context.Context, arg CreateCoverArtParams) (CoverArt, error) {
row := q.db.QueryRowContext(ctx, createCoverArt, arg.IsEmbedded, arg.FilePath, arg.FileTypeID)
var i CoverArt
err := row.Scan(
&i.ID,
&i.IsEmbedded,
&i.FilePath,
&i.FileTypeID,
)
return i, err
}
const deleteCoverArt = `-- name: DeleteCoverArt :exec
DELETE FROM cover_art
WHERE id =?
`
func (q *Queries) DeleteCoverArt(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteCoverArt, id)
return err
}
const getCoverArt = `-- name: GetCoverArt :one
SELECT id, is_embedded, file_path, file_type_id FROM cover_art
WHERE id = ? LIMIT 1
`
func (q *Queries) GetCoverArt(ctx context.Context, id int64) (CoverArt, error) {
row := q.db.QueryRowContext(ctx, getCoverArt, id)
var i CoverArt
err := row.Scan(
&i.ID,
&i.IsEmbedded,
&i.FilePath,
&i.FileTypeID,
)
return i, err
}
const updateCoverArt = `-- name: UpdateCoverArt :exec
UPDATE cover_art
SET is_embedded = ?, file_path = ?, file_type_id = ?
WHERE id =?
`
type UpdateCoverArtParams struct {
IsEmbedded bool
FilePath string
FileTypeID int64
ID int64
}
func (q *Queries) UpdateCoverArt(ctx context.Context, arg UpdateCoverArtParams) error {
_, err := q.db.ExecContext(ctx, updateCoverArt,
arg.IsEmbedded,
arg.FilePath,
arg.FileTypeID,
arg.ID,
)
return err
}
+31
View File
@@ -0,0 +1,31 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
package sqlcgen
import (
"context"
"database/sql"
)
type DBTX interface {
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
PrepareContext(context.Context, string) (*sql.Stmt, error)
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}
func New(db DBTX) *Queries {
return &Queries{db: db}
}
type Queries struct {
db DBTX
}
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
return &Queries{
db: tx,
}
}
@@ -0,0 +1,60 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: file_types.sql
package sqlcgen
import (
"context"
)
const createFileType = `-- name: CreateFileType :one
INSERT INTO file_types (extension) VALUES (?)
RETURNING id, extension
`
func (q *Queries) CreateFileType(ctx context.Context, extension string) (FileType, error) {
row := q.db.QueryRowContext(ctx, createFileType, extension)
var i FileType
err := row.Scan(&i.ID, &i.Extension)
return i, err
}
const deleteFileType = `-- name: DeleteFileType :exec
DELETE FROM file_types
WHERE id =?
`
func (q *Queries) DeleteFileType(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteFileType, id)
return err
}
const getFileType = `-- name: GetFileType :one
SELECT id, extension FROM file_types
WHERE id = ? LIMIT 1
`
func (q *Queries) GetFileType(ctx context.Context, id int64) (FileType, error) {
row := q.db.QueryRowContext(ctx, getFileType, id)
var i FileType
err := row.Scan(&i.ID, &i.Extension)
return i, err
}
const updateFileType = `-- name: UpdateFileType :exec
UPDATE file_types
SET extension = ?
WHERE id =?
`
type UpdateFileTypeParams struct {
Extension string
ID int64
}
func (q *Queries) UpdateFileType(ctx context.Context, arg UpdateFileTypeParams) error {
_, err := q.db.ExecContext(ctx, updateFileType, arg.Extension, arg.ID)
return err
}
+59
View File
@@ -0,0 +1,59 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
package sqlcgen
type Artist struct {
ID int64
Name string
}
type ArtistCredit struct {
ID int64
Text interface{}
}
type ArtistCreditArtist struct {
ID int64
ArtistID int64
CreditID int64
}
type AudioFile struct {
ID int64
FilePath string
LengthMilliseconds int64
FileTypeID int64
RecordingID int64
}
type CoverArt struct {
ID int64
IsEmbedded bool
FilePath string
FileTypeID int64
}
type FileType struct {
ID int64
Extension string
}
type Recording struct {
ID int64
Name string
ArtistCreditID int64
}
type ReleaseGroup struct {
ID int64
Name string
CoverArtID int64
}
type ReleaseGroupRecording struct {
ID int64
ReleaseGroupID int64
RecordingID int64
}
@@ -0,0 +1,60 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: recordings.sql
package sqlcgen
import (
"context"
)
const createRecording = `-- name: CreateRecording :one
INSERT INTO recordings (name) VALUES (?)
RETURNING id, name, artist_credit_id
`
func (q *Queries) CreateRecording(ctx context.Context, name string) (Recording, error) {
row := q.db.QueryRowContext(ctx, createRecording, name)
var i Recording
err := row.Scan(&i.ID, &i.Name, &i.ArtistCreditID)
return i, err
}
const deleteRecording = `-- name: DeleteRecording :exec
DELETE FROM recordings
WHERE id =?
`
func (q *Queries) DeleteRecording(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteRecording, id)
return err
}
const getRecording = `-- name: GetRecording :one
SELECT id, name, artist_credit_id FROM recordings
WHERE id = ? LIMIT 1
`
func (q *Queries) GetRecording(ctx context.Context, id int64) (Recording, error) {
row := q.db.QueryRowContext(ctx, getRecording, id)
var i Recording
err := row.Scan(&i.ID, &i.Name, &i.ArtistCreditID)
return i, err
}
const updateRecording = `-- name: UpdateRecording :exec
UPDATE recordings
SET name = ?
WHERE id =?
`
type UpdateRecordingParams struct {
Name string
ID int64
}
func (q *Queries) UpdateRecording(ctx context.Context, arg UpdateRecordingParams) error {
_, err := q.db.ExecContext(ctx, updateRecording, arg.Name, arg.ID)
return err
}
@@ -0,0 +1,66 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: release_group_recordings.sql
package sqlcgen
import (
"context"
)
const createReleaseGroupRecording = `-- name: CreateReleaseGroupRecording :one
INSERT INTO release_group_recordings (release_group_id, recording_id) VALUES (?,?)
RETURNING id, release_group_id, recording_id
`
type CreateReleaseGroupRecordingParams struct {
ReleaseGroupID int64
RecordingID int64
}
func (q *Queries) CreateReleaseGroupRecording(ctx context.Context, arg CreateReleaseGroupRecordingParams) (ReleaseGroupRecording, error) {
row := q.db.QueryRowContext(ctx, createReleaseGroupRecording, arg.ReleaseGroupID, arg.RecordingID)
var i ReleaseGroupRecording
err := row.Scan(&i.ID, &i.ReleaseGroupID, &i.RecordingID)
return i, err
}
const deleteReleaseGroupRecording = `-- name: DeleteReleaseGroupRecording :exec
DELETE FROM release_group_recordings
WHERE id =?
`
func (q *Queries) DeleteReleaseGroupRecording(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteReleaseGroupRecording, id)
return err
}
const getReleaseGroupRecording = `-- name: GetReleaseGroupRecording :one
SELECT id, release_group_id, recording_id FROM release_group_recordings
WHERE id = ? LIMIT 1
`
func (q *Queries) GetReleaseGroupRecording(ctx context.Context, id int64) (ReleaseGroupRecording, error) {
row := q.db.QueryRowContext(ctx, getReleaseGroupRecording, id)
var i ReleaseGroupRecording
err := row.Scan(&i.ID, &i.ReleaseGroupID, &i.RecordingID)
return i, err
}
const updateReleaseGroupRecording = `-- name: UpdateReleaseGroupRecording :exec
UPDATE release_group_recordings
SET release_group_id = ?, recording_id = ?
WHERE id =?
`
type UpdateReleaseGroupRecordingParams struct {
ReleaseGroupID int64
RecordingID int64
ID int64
}
func (q *Queries) UpdateReleaseGroupRecording(ctx context.Context, arg UpdateReleaseGroupRecordingParams) error {
_, err := q.db.ExecContext(ctx, updateReleaseGroupRecording, arg.ReleaseGroupID, arg.RecordingID, arg.ID)
return err
}
@@ -0,0 +1,60 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.28.0
// source: release_groups.sql
package sqlcgen
import (
"context"
)
const createReleaseGroup = `-- name: CreateReleaseGroup :one
INSERT INTO release_groups (name) VALUES (?)
RETURNING id, name, cover_art_id
`
func (q *Queries) CreateReleaseGroup(ctx context.Context, name string) (ReleaseGroup, error) {
row := q.db.QueryRowContext(ctx, createReleaseGroup, name)
var i ReleaseGroup
err := row.Scan(&i.ID, &i.Name, &i.CoverArtID)
return i, err
}
const deleteReleaseGroup = `-- name: DeleteReleaseGroup :exec
DELETE FROM release_groups
WHERE id =?
`
func (q *Queries) DeleteReleaseGroup(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteReleaseGroup, id)
return err
}
const getReleaseGroup = `-- name: GetReleaseGroup :one
SELECT id, name, cover_art_id FROM release_groups
WHERE id = ? LIMIT 1
`
func (q *Queries) GetReleaseGroup(ctx context.Context, id int64) (ReleaseGroup, error) {
row := q.db.QueryRowContext(ctx, getReleaseGroup, id)
var i ReleaseGroup
err := row.Scan(&i.ID, &i.Name, &i.CoverArtID)
return i, err
}
const updateReleaseGroup = `-- name: UpdateReleaseGroup :exec
UPDATE release_groups
SET name = ?
WHERE id =?
`
type UpdateReleaseGroupParams struct {
Name string
ID int64
}
func (q *Queries) UpdateReleaseGroup(ctx context.Context, arg UpdateReleaseGroupParams) error {
_, err := q.db.ExecContext(ctx, updateReleaseGroup, arg.Name, arg.ID)
return err
}
+2 -2
View File
@@ -6,5 +6,5 @@ sql:
schema: "./sql/schemas"
gen:
go:
package: "sql"
out: "sql"
package: "sqlcgen"
out: "./sql/sqlcgen"
+8
View File
@@ -8,10 +8,12 @@ require (
github.com/BurntSushi/toml v1.5.0
github.com/gopxl/beep v1.4.1
github.com/wailsapp/wails/v2 v2.10.1
modernc.org/sqlite v1.37.0
)
require (
github.com/bep/debounce v1.2.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ebitengine/oto/v3 v3.3.3 // indirect
github.com/ebitengine/purego v0.8.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
@@ -27,8 +29,10 @@ require (
github.com/leaanthony/u v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/samber/lo v1.49.1 // indirect
github.com/tkrajina/go-reflector v0.5.8 // indirect
@@ -37,9 +41,13 @@ require (
github.com/wailsapp/go-webview2 v1.0.21 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect
modernc.org/libc v1.62.1 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.9.1 // indirect
)
// replace github.com/wailsapp/wails/v2 v2.10.1 => /home/logan/go/pkg/mod
+40
View File
@@ -4,6 +4,8 @@ github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/ebitengine/oto/v3 v3.3.3 h1:m6RV69OqoXYSWCDsHXN9rc07aDuDstGHtait7HXSM7g=
github.com/ebitengine/oto/v3 v3.3.3/go.mod h1:MZeb/lwoC4DCOdiTIxYezrURTw7EvK/yF863+tmBI+U=
github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I=
@@ -12,6 +14,8 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopxl/beep v1.4.1 h1:WqNs9RsDAhG9M3khMyc1FaVY50dTdxG/6S6a3qsUHqE=
@@ -42,12 +46,16 @@ github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHP
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
@@ -69,9 +77,15 @@ github.com/wailsapp/wails/v2 v2.10.1 h1:QWHvWMXII2nI/nXz77gpPG8P3ehl6zKe+u4su5BW
github.com/wailsapp/wails/v2 v2.10.1/go.mod h1:zrebnFV6MQf9kx8HI4iAv63vsR5v67oS7GTEZ7Pz1TY=
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -85,5 +99,31 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/cc/v4 v4.25.2 h1:T2oH7sZdGvTaie0BRNFbIYsabzCxUQg8nLqCdQ2i0ic=
modernc.org/cc/v4 v4.25.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
modernc.org/ccgo/v4 v4.25.1 h1:TFSzPrAGmDsdnhT9X2UrcPMI3N/mJ9/X9ykKXwLhDsU=
modernc.org/ccgo/v4 v4.25.1/go.mod h1:njjuAYiPflywOOrm3B7kCB444ONP5pAVr8PIEoE0uDw=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
modernc.org/libc v1.62.1 h1:s0+fv5E3FymN8eJVmnk0llBe6rOxCu/DEU+XygRbS8s=
modernc.org/libc v1.62.1/go.mod h1:iXhATfJQLjG3NWy56a6WVU73lWOcdYVxsvwCgoPljuo=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.9.1 h1:V/Z1solwAVmMW1yttq3nDdZPJqV1rM05Ccq6KMSZ34g=
modernc.org/memory v1.9.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI=
modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=