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).
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: pool_assignments.sql
|
|
|
|
package entitlements
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createPoolAssignment = `-- name: CreatePoolAssignment :one
|
|
INSERT INTO entitlements.pool_assignments (pool_id, workspace_id, is_primary)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING assignment_id, pool_id, workspace_id, is_primary, status, suspended_at, created_at, updated_at
|
|
`
|
|
|
|
type CreatePoolAssignmentParams struct {
|
|
PoolID string `json:"pool_id"`
|
|
WorkspaceID string `json:"workspace_id"`
|
|
IsPrimary bool `json:"is_primary"`
|
|
}
|
|
|
|
func (q *Queries) CreatePoolAssignment(ctx context.Context, arg CreatePoolAssignmentParams) (PoolAssignment, error) {
|
|
row := q.db.QueryRowContext(ctx, createPoolAssignment, arg.PoolID, arg.WorkspaceID, arg.IsPrimary)
|
|
var i PoolAssignment
|
|
err := row.Scan(
|
|
&i.AssignmentID,
|
|
&i.PoolID,
|
|
&i.WorkspaceID,
|
|
&i.IsPrimary,
|
|
&i.Status,
|
|
&i.SuspendedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPrimaryPoolAssignmentByWorkspace = `-- name: GetPrimaryPoolAssignmentByWorkspace :one
|
|
SELECT assignment_id, pool_id, workspace_id, is_primary, status, suspended_at, created_at, updated_at FROM entitlements.pool_assignments
|
|
WHERE workspace_id = $1 AND is_primary = TRUE AND status = 'active'
|
|
`
|
|
|
|
func (q *Queries) GetPrimaryPoolAssignmentByWorkspace(ctx context.Context, workspaceID string) (PoolAssignment, error) {
|
|
row := q.db.QueryRowContext(ctx, getPrimaryPoolAssignmentByWorkspace, workspaceID)
|
|
var i PoolAssignment
|
|
err := row.Scan(
|
|
&i.AssignmentID,
|
|
&i.PoolID,
|
|
&i.WorkspaceID,
|
|
&i.IsPrimary,
|
|
&i.Status,
|
|
&i.SuspendedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|