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).
81 lines
1.9 KiB
Go
81 lines
1.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: users.sql
|
|
|
|
package identity
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO identity.users (oidc_subject)
|
|
VALUES ($1)
|
|
RETURNING user_id, oidc_subject, status, last_login_at, last_login_ip, created_at, updated_at
|
|
`
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, oidcSubject string) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, createUser, oidcSubject)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.UserID,
|
|
&i.OidcSubject,
|
|
&i.Status,
|
|
&i.LastLoginAt,
|
|
&i.LastLoginIp,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByOIDCSubject = `-- name: GetUserByOIDCSubject :one
|
|
SELECT user_id, oidc_subject, status, last_login_at, last_login_ip, created_at, updated_at FROM identity.users
|
|
WHERE oidc_subject = $1
|
|
`
|
|
|
|
func (q *Queries) GetUserByOIDCSubject(ctx context.Context, oidcSubject string) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByOIDCSubject, oidcSubject)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.UserID,
|
|
&i.OidcSubject,
|
|
&i.Status,
|
|
&i.LastLoginAt,
|
|
&i.LastLoginIp,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateUserLogin = `-- name: UpdateUserLogin :one
|
|
UPDATE identity.users
|
|
SET last_login_at = $1, last_login_ip = $2
|
|
WHERE user_id = $3
|
|
RETURNING user_id, oidc_subject, status, last_login_at, last_login_ip, created_at, updated_at
|
|
`
|
|
|
|
type UpdateUserLoginParams struct {
|
|
LastLoginAt sql.NullTime `json:"last_login_at"`
|
|
LastLoginIp sql.NullString `json:"last_login_ip"`
|
|
UserID string `json:"user_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateUserLogin(ctx context.Context, arg UpdateUserLoginParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, updateUserLogin, arg.LastLoginAt, arg.LastLoginIp, arg.UserID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.UserID,
|
|
&i.OidcSubject,
|
|
&i.Status,
|
|
&i.LastLoginAt,
|
|
&i.LastLoginIp,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|