Drop redundant schema prefixes from all sqlc-generated Go types. Since each module generates into its own package, the package already provides the namespace — billing.Account is unambiguous without billing.BillingAccount. Changes: - Add rename: blocks to all 6 sqlc.yaml files mapping schema-prefixed names to clean idiomatic names (e.g. BillingBillingAccount → Account, IdentityPerson → Person, OrganizationOrganization → Organization) - Rename billing.billing_accounts → billing.accounts (table name repeated the schema; the schema already provides that context) - Rename integration.integration_outbox → integration.outbox (same reason) - Regenerate all sqlc output across billing, identity, organization, entitlements, stripe, and fedwiki modules - Update all calling code (server, workflows, provisioning, tests) to use the new names - Add internal/db/sqlc_schemas.sql — sqlc-only schema declarations so every module can resolve schema-qualified names without including the full db migrations - Update docs/database-management.md with the naming convention and standard sqlc.yaml template Convention going forward: table names must not repeat the schema name; generated types carry no schema prefix; the Go package provides the namespace (like http.Request, not http.HttpRequest).
161 lines
3.8 KiB
Go
161 lines
3.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: entitlement_sets.sql
|
|
|
|
package entitlements
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createEntitlementSet = `-- name: CreateEntitlementSet :one
|
|
INSERT INTO entitlements.entitlement_sets (name, description, is_active)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING set_id, name, description, is_active, created_at, updated_at
|
|
`
|
|
|
|
type CreateEntitlementSetParams struct {
|
|
Name string `json:"name"`
|
|
Description sql.NullString `json:"description"`
|
|
IsActive bool `json:"is_active"`
|
|
}
|
|
|
|
func (q *Queries) CreateEntitlementSet(ctx context.Context, arg CreateEntitlementSetParams) (EntitlementSet, error) {
|
|
row := q.db.QueryRowContext(ctx, createEntitlementSet, arg.Name, arg.Description, arg.IsActive)
|
|
var i EntitlementSet
|
|
err := row.Scan(
|
|
&i.SetID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getEntitlementSetByID = `-- name: GetEntitlementSetByID :one
|
|
SELECT set_id, name, description, is_active, created_at, updated_at FROM entitlements.entitlement_sets
|
|
WHERE set_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetEntitlementSetByID(ctx context.Context, setID string) (EntitlementSet, error) {
|
|
row := q.db.QueryRowContext(ctx, getEntitlementSetByID, setID)
|
|
var i EntitlementSet
|
|
err := row.Scan(
|
|
&i.SetID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listActiveEntitlementSets = `-- name: ListActiveEntitlementSets :many
|
|
SELECT set_id, name, description, is_active, created_at, updated_at FROM entitlements.entitlement_sets
|
|
WHERE is_active = TRUE
|
|
ORDER BY name ASC
|
|
`
|
|
|
|
func (q *Queries) ListActiveEntitlementSets(ctx context.Context) ([]EntitlementSet, error) {
|
|
rows, err := q.db.QueryContext(ctx, listActiveEntitlementSets)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []EntitlementSet{}
|
|
for rows.Next() {
|
|
var i EntitlementSet
|
|
if err := rows.Scan(
|
|
&i.SetID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listEntitlementSets = `-- name: ListEntitlementSets :many
|
|
SELECT set_id, name, description, is_active, created_at, updated_at FROM entitlements.entitlement_sets
|
|
ORDER BY name ASC
|
|
`
|
|
|
|
func (q *Queries) ListEntitlementSets(ctx context.Context) ([]EntitlementSet, error) {
|
|
rows, err := q.db.QueryContext(ctx, listEntitlementSets)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []EntitlementSet{}
|
|
for rows.Next() {
|
|
var i EntitlementSet
|
|
if err := rows.Scan(
|
|
&i.SetID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const updateEntitlementSet = `-- name: UpdateEntitlementSet :one
|
|
UPDATE entitlements.entitlement_sets
|
|
SET name = $2, description = $3, is_active = $4
|
|
WHERE set_id = $1
|
|
RETURNING set_id, name, description, is_active, created_at, updated_at
|
|
`
|
|
|
|
type UpdateEntitlementSetParams struct {
|
|
SetID string `json:"set_id"`
|
|
Name string `json:"name"`
|
|
Description sql.NullString `json:"description"`
|
|
IsActive bool `json:"is_active"`
|
|
}
|
|
|
|
func (q *Queries) UpdateEntitlementSet(ctx context.Context, arg UpdateEntitlementSetParams) (EntitlementSet, error) {
|
|
row := q.db.QueryRowContext(ctx, updateEntitlementSet,
|
|
arg.SetID,
|
|
arg.Name,
|
|
arg.Description,
|
|
arg.IsActive,
|
|
)
|
|
var i EntitlementSet
|
|
err := row.Scan(
|
|
&i.SetID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|