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).
93 lines
3.0 KiB
Go
93 lines
3.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: customer_mappings.sql
|
|
|
|
package stripe
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const getCustomerMappingByBillingAccountID = `-- name: GetCustomerMappingByBillingAccountID :one
|
|
SELECT billing_account_id, stripe_customer_id, sync_status, created_at, updated_at FROM stripe.customer_mappings
|
|
WHERE billing_account_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetCustomerMappingByBillingAccountID(ctx context.Context, billingAccountID string) (CustomerMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, getCustomerMappingByBillingAccountID, billingAccountID)
|
|
var i CustomerMapping
|
|
err := row.Scan(
|
|
&i.BillingAccountID,
|
|
&i.StripeCustomerID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getCustomerMappingByStripeCustomerID = `-- name: GetCustomerMappingByStripeCustomerID :one
|
|
SELECT billing_account_id, stripe_customer_id, sync_status, created_at, updated_at FROM stripe.customer_mappings
|
|
WHERE stripe_customer_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetCustomerMappingByStripeCustomerID(ctx context.Context, stripeCustomerID sql.NullString) (CustomerMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, getCustomerMappingByStripeCustomerID, stripeCustomerID)
|
|
var i CustomerMapping
|
|
err := row.Scan(
|
|
&i.BillingAccountID,
|
|
&i.StripeCustomerID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateCustomerMappingSyncStatus = `-- name: UpdateCustomerMappingSyncStatus :exec
|
|
UPDATE stripe.customer_mappings
|
|
SET sync_status = $2, updated_at = NOW()
|
|
WHERE billing_account_id = $1
|
|
`
|
|
|
|
type UpdateCustomerMappingSyncStatusParams struct {
|
|
BillingAccountID string `json:"billing_account_id"`
|
|
SyncStatus string `json:"sync_status"`
|
|
}
|
|
|
|
func (q *Queries) UpdateCustomerMappingSyncStatus(ctx context.Context, arg UpdateCustomerMappingSyncStatusParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateCustomerMappingSyncStatus, arg.BillingAccountID, arg.SyncStatus)
|
|
return err
|
|
}
|
|
|
|
const upsertCustomerMapping = `-- name: UpsertCustomerMapping :one
|
|
INSERT INTO stripe.customer_mappings (billing_account_id, stripe_customer_id, sync_status)
|
|
VALUES ($1, $2, $3)
|
|
ON CONFLICT (billing_account_id) DO UPDATE
|
|
SET stripe_customer_id = EXCLUDED.stripe_customer_id,
|
|
sync_status = EXCLUDED.sync_status,
|
|
updated_at = NOW()
|
|
RETURNING billing_account_id, stripe_customer_id, sync_status, created_at, updated_at
|
|
`
|
|
|
|
type UpsertCustomerMappingParams struct {
|
|
BillingAccountID string `json:"billing_account_id"`
|
|
StripeCustomerID sql.NullString `json:"stripe_customer_id"`
|
|
SyncStatus string `json:"sync_status"`
|
|
}
|
|
|
|
func (q *Queries) UpsertCustomerMapping(ctx context.Context, arg UpsertCustomerMappingParams) (CustomerMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, upsertCustomerMapping, arg.BillingAccountID, arg.StripeCustomerID, arg.SyncStatus)
|
|
var i CustomerMapping
|
|
err := row.Scan(
|
|
&i.BillingAccountID,
|
|
&i.StripeCustomerID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|