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.1 KiB
Go
93 lines
3.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: subscription_mappings.sql
|
|
|
|
package stripe
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const getSubscriptionMappingByStripeID = `-- name: GetSubscriptionMappingByStripeID :one
|
|
SELECT subscription_id, stripe_subscription_id, sync_status, created_at, updated_at FROM stripe.subscription_mappings
|
|
WHERE stripe_subscription_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetSubscriptionMappingByStripeID(ctx context.Context, stripeSubscriptionID sql.NullString) (SubscriptionMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, getSubscriptionMappingByStripeID, stripeSubscriptionID)
|
|
var i SubscriptionMapping
|
|
err := row.Scan(
|
|
&i.SubscriptionID,
|
|
&i.StripeSubscriptionID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getSubscriptionMappingBySubscriptionID = `-- name: GetSubscriptionMappingBySubscriptionID :one
|
|
SELECT subscription_id, stripe_subscription_id, sync_status, created_at, updated_at FROM stripe.subscription_mappings
|
|
WHERE subscription_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetSubscriptionMappingBySubscriptionID(ctx context.Context, subscriptionID string) (SubscriptionMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, getSubscriptionMappingBySubscriptionID, subscriptionID)
|
|
var i SubscriptionMapping
|
|
err := row.Scan(
|
|
&i.SubscriptionID,
|
|
&i.StripeSubscriptionID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateSubscriptionMappingSyncStatus = `-- name: UpdateSubscriptionMappingSyncStatus :exec
|
|
UPDATE stripe.subscription_mappings
|
|
SET sync_status = $2, updated_at = NOW()
|
|
WHERE subscription_id = $1
|
|
`
|
|
|
|
type UpdateSubscriptionMappingSyncStatusParams struct {
|
|
SubscriptionID string `json:"subscription_id"`
|
|
SyncStatus string `json:"sync_status"`
|
|
}
|
|
|
|
func (q *Queries) UpdateSubscriptionMappingSyncStatus(ctx context.Context, arg UpdateSubscriptionMappingSyncStatusParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateSubscriptionMappingSyncStatus, arg.SubscriptionID, arg.SyncStatus)
|
|
return err
|
|
}
|
|
|
|
const upsertSubscriptionMapping = `-- name: UpsertSubscriptionMapping :one
|
|
INSERT INTO stripe.subscription_mappings (subscription_id, stripe_subscription_id, sync_status)
|
|
VALUES ($1, $2, $3)
|
|
ON CONFLICT (subscription_id) DO UPDATE
|
|
SET stripe_subscription_id = EXCLUDED.stripe_subscription_id,
|
|
sync_status = EXCLUDED.sync_status,
|
|
updated_at = NOW()
|
|
RETURNING subscription_id, stripe_subscription_id, sync_status, created_at, updated_at
|
|
`
|
|
|
|
type UpsertSubscriptionMappingParams struct {
|
|
SubscriptionID string `json:"subscription_id"`
|
|
StripeSubscriptionID sql.NullString `json:"stripe_subscription_id"`
|
|
SyncStatus string `json:"sync_status"`
|
|
}
|
|
|
|
func (q *Queries) UpsertSubscriptionMapping(ctx context.Context, arg UpsertSubscriptionMappingParams) (SubscriptionMapping, error) {
|
|
row := q.db.QueryRowContext(ctx, upsertSubscriptionMapping, arg.SubscriptionID, arg.StripeSubscriptionID, arg.SyncStatus)
|
|
var i SubscriptionMapping
|
|
err := row.Scan(
|
|
&i.SubscriptionID,
|
|
&i.StripeSubscriptionID,
|
|
&i.SyncStatus,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|