mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
* refactor(db): port operations, settings, audit, activity, and misc service metadata to sqlc Covers the cross-cutting surface: operations board reads, app settings, notification producers, activity/audit inserts, builds upsert/cancel, git clone credential resolution, invites, environments, registry auth, project/service variables, HA resolver, boot sweeps, and admin user ops. Dynamic filtered lists and Better Auth table probes stay raw by design. Authored By: TDvorak <[email protected]> * refactor(db): port apwhy gateway handlers and proxy data plane to sqlc Final tranche — every static call site now uses generated queries. Raw SQL remains only where the statement is assembled at runtime (filtered lists, sparse updates, admin count closure) or probes Better Auth's auth_users table, which lives outside the local schema. Authored By: TDvorak <[email protected]>
175 lines
4.9 KiB
Go
175 lines
4.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: misc.sql
|
|
|
|
package sqlcdb
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const countProjects = `-- name: CountProjects :one
|
|
SELECT COUNT(*) FROM projects
|
|
`
|
|
|
|
func (q *Queries) CountProjects(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countProjects)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const deleteProjectVariables = `-- name: DeleteProjectVariables :exec
|
|
DELETE FROM project_variables WHERE project_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteProjectVariables(ctx context.Context, projectID uuid.UUID) error {
|
|
_, err := q.db.ExecContext(ctx, deleteProjectVariables, projectID)
|
|
return err
|
|
}
|
|
|
|
const getProjectVariableValue = `-- name: GetProjectVariableValue :one
|
|
SELECT value FROM project_variables WHERE project_id = $1 AND key = $2
|
|
`
|
|
|
|
type GetProjectVariableValueParams struct {
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
Key string `json:"key"`
|
|
}
|
|
|
|
func (q *Queries) GetProjectVariableValue(ctx context.Context, arg GetProjectVariableValueParams) (string, error) {
|
|
row := q.db.QueryRowContext(ctx, getProjectVariableValue, arg.ProjectID, arg.Key)
|
|
var value string
|
|
err := row.Scan(&value)
|
|
return value, err
|
|
}
|
|
|
|
const getRegistryAuth = `-- name: GetRegistryAuth :one
|
|
SELECT username, password FROM registries
|
|
WHERE owner_id::text = $1 AND host = $2
|
|
`
|
|
|
|
type GetRegistryAuthParams struct {
|
|
OwnerID uuid.UUID `json:"owner_id"`
|
|
Host string `json:"host"`
|
|
}
|
|
|
|
type GetRegistryAuthRow struct {
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
func (q *Queries) GetRegistryAuth(ctx context.Context, arg GetRegistryAuthParams) (GetRegistryAuthRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getRegistryAuth, arg.OwnerID, arg.Host)
|
|
var i GetRegistryAuthRow
|
|
err := row.Scan(&i.Username, &i.Password)
|
|
return i, err
|
|
}
|
|
|
|
const insertEnvVar = `-- name: InsertEnvVar :exec
|
|
INSERT INTO environment_variables (id, service_id, key, value, is_secret, created_at, updated_at)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
`
|
|
|
|
type InsertEnvVarParams struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ServiceID uuid.UUID `json:"service_id"`
|
|
Key string `json:"key"`
|
|
Value string `json:"value"`
|
|
IsSecret sql.NullBool `json:"is_secret"`
|
|
CreatedAt sql.NullTime `json:"created_at"`
|
|
UpdatedAt sql.NullTime `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) InsertEnvVar(ctx context.Context, arg InsertEnvVarParams) error {
|
|
_, err := q.db.ExecContext(ctx, insertEnvVar,
|
|
arg.ID,
|
|
arg.ServiceID,
|
|
arg.Key,
|
|
arg.Value,
|
|
arg.IsSecret,
|
|
arg.CreatedAt,
|
|
arg.UpdatedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const insertProjectVariable = `-- name: InsertProjectVariable :exec
|
|
INSERT INTO project_variables (id, project_id, key, value, is_secret, created_at, updated_at)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
`
|
|
|
|
type InsertProjectVariableParams struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
Key string `json:"key"`
|
|
Value string `json:"value"`
|
|
IsSecret bool `json:"is_secret"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) InsertProjectVariable(ctx context.Context, arg InsertProjectVariableParams) error {
|
|
_, err := q.db.ExecContext(ctx, insertProjectVariable,
|
|
arg.ID,
|
|
arg.ProjectID,
|
|
arg.Key,
|
|
arg.Value,
|
|
arg.IsSecret,
|
|
arg.CreatedAt,
|
|
arg.UpdatedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateServiceDeployMeta = `-- name: UpdateServiceDeployMeta :exec
|
|
UPDATE services SET port = $1, healthcheck_path = $2,
|
|
volumes = COALESCE($3::jsonb, '[]'::jsonb),
|
|
git_repo = NULLIF($4::text, ''), git_branch = NULLIF($5::text, ''), builder = $6
|
|
WHERE id = $7
|
|
`
|
|
|
|
type UpdateServiceDeployMetaParams struct {
|
|
Port int32 `json:"port"`
|
|
HealthcheckPath string `json:"healthcheck_path"`
|
|
Column3 json.RawMessage `json:"column_3"`
|
|
Column4 string `json:"column_4"`
|
|
Column5 string `json:"column_5"`
|
|
Builder string `json:"builder"`
|
|
ID uuid.UUID `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateServiceDeployMeta(ctx context.Context, arg UpdateServiceDeployMetaParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateServiceDeployMeta,
|
|
arg.Port,
|
|
arg.HealthcheckPath,
|
|
arg.Column3,
|
|
arg.Column4,
|
|
arg.Column5,
|
|
arg.Builder,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateServiceRuntimeMeta = `-- name: UpdateServiceRuntimeMeta :exec
|
|
UPDATE services SET port = $1, healthcheck_path = $2 WHERE id = $3
|
|
`
|
|
|
|
type UpdateServiceRuntimeMetaParams struct {
|
|
Port int32 `json:"port"`
|
|
HealthcheckPath string `json:"healthcheck_path"`
|
|
ID uuid.UUID `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateServiceRuntimeMeta(ctx context.Context, arg UpdateServiceRuntimeMetaParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateServiceRuntimeMeta, arg.Port, arg.HealthcheckPath, arg.ID)
|
|
return err
|
|
}
|