Add initial database setup and user/artist management functionality

This commit is contained in:
zardzul
2026-03-13 20:42:50 +01:00
parent 5fa23b0d1c
commit f81b28417e
26 changed files with 585 additions and 64 deletions
+58
View File
@@ -0,0 +1,58 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: users.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const checkUserExistsByEmail = `-- name: CheckUserExistsByEmail :one
SELECT id FROM users WHERE user_mail = $1
`
func (q *Queries) CheckUserExistsByEmail(ctx context.Context, userMail string) (pgtype.UUID, error) {
row := q.db.QueryRow(ctx, checkUserExistsByEmail, userMail)
var id pgtype.UUID
err := row.Scan(&id)
return id, err
}
const createUser = `-- name: CreateUser :one
INSERT INTO users (id, user_name, user_mail, password) VALUES ($1, $2, $3, $4) RETURNING id
`
type CreateUserParams struct {
ID pgtype.UUID `json:"id"`
UserName string `json:"user_name"`
UserMail string `json:"user_mail"`
Password string `json:"password"`
}
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (pgtype.UUID, error) {
row := q.db.QueryRow(ctx, createUser,
arg.ID,
arg.UserName,
arg.UserMail,
arg.Password,
)
var id pgtype.UUID
err := row.Scan(&id)
return id, err
}
const getUsernameByID = `-- name: GetUsernameByID :one
SELECT user_name FROM users WHERE id = $1
`
// users.sql
func (q *Queries) GetUsernameByID(ctx context.Context, id pgtype.UUID) (string, error) {
row := q.db.QueryRow(ctx, getUsernameByID, id)
var user_name string
err := row.Scan(&user_name)
return user_name, err
}