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).
80 lines
2.1 KiB
Go
80 lines
2.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: subscription_changes.sql
|
|
|
|
package billing
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createSubscriptionChange = `-- name: CreateSubscriptionChange :one
|
|
INSERT INTO billing.subscription_changes (subscription_id, previous_status, new_status, stripe_event_id)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING change_id, subscription_id, previous_status, new_status, stripe_event_id, changed_at
|
|
`
|
|
|
|
type CreateSubscriptionChangeParams struct {
|
|
SubscriptionID string `json:"subscription_id"`
|
|
PreviousStatus sql.NullString `json:"previous_status"`
|
|
NewStatus string `json:"new_status"`
|
|
StripeEventID string `json:"stripe_event_id"`
|
|
}
|
|
|
|
func (q *Queries) CreateSubscriptionChange(ctx context.Context, arg CreateSubscriptionChangeParams) (SubscriptionChange, error) {
|
|
row := q.db.QueryRowContext(ctx, createSubscriptionChange,
|
|
arg.SubscriptionID,
|
|
arg.PreviousStatus,
|
|
arg.NewStatus,
|
|
arg.StripeEventID,
|
|
)
|
|
var i SubscriptionChange
|
|
err := row.Scan(
|
|
&i.ChangeID,
|
|
&i.SubscriptionID,
|
|
&i.PreviousStatus,
|
|
&i.NewStatus,
|
|
&i.StripeEventID,
|
|
&i.ChangedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getSubscriptionChangesBySubscriptionID = `-- name: GetSubscriptionChangesBySubscriptionID :many
|
|
SELECT change_id, subscription_id, previous_status, new_status, stripe_event_id, changed_at FROM billing.subscription_changes
|
|
WHERE subscription_id = $1
|
|
ORDER BY changed_at ASC
|
|
`
|
|
|
|
func (q *Queries) GetSubscriptionChangesBySubscriptionID(ctx context.Context, subscriptionID string) ([]SubscriptionChange, error) {
|
|
rows, err := q.db.QueryContext(ctx, getSubscriptionChangesBySubscriptionID, subscriptionID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []SubscriptionChange{}
|
|
for rows.Next() {
|
|
var i SubscriptionChange
|
|
if err := rows.Scan(
|
|
&i.ChangeID,
|
|
&i.SubscriptionID,
|
|
&i.PreviousStatus,
|
|
&i.NewStatus,
|
|
&i.StripeEventID,
|
|
&i.ChangedAt,
|
|
); 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
|
|
}
|