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).
129 lines
3.4 KiB
Go
129 lines
3.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: members.sql
|
|
|
|
package organization
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
const createOrgMember = `-- name: CreateOrgMember :one
|
|
INSERT INTO organization.org_members (org_id, person_id, role_id)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING org_member_id, org_id, person_id, role_id, status, joined_at, removed_at, created_at, updated_at
|
|
`
|
|
|
|
type CreateOrgMemberParams struct {
|
|
OrgID string `json:"org_id"`
|
|
PersonID string `json:"person_id"`
|
|
RoleID string `json:"role_id"`
|
|
}
|
|
|
|
func (q *Queries) CreateOrgMember(ctx context.Context, arg CreateOrgMemberParams) (OrgMember, error) {
|
|
row := q.db.QueryRowContext(ctx, createOrgMember, arg.OrgID, arg.PersonID, arg.RoleID)
|
|
var i OrgMember
|
|
err := row.Scan(
|
|
&i.OrgMemberID,
|
|
&i.OrgID,
|
|
&i.PersonID,
|
|
&i.RoleID,
|
|
&i.Status,
|
|
&i.JoinedAt,
|
|
&i.RemovedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getOrgMemberByPersonAndOrg = `-- name: GetOrgMemberByPersonAndOrg :one
|
|
SELECT org_member_id, org_id, person_id, role_id, status, joined_at, removed_at, created_at, updated_at FROM organization.org_members
|
|
WHERE person_id = $1 AND org_id = $2
|
|
`
|
|
|
|
type GetOrgMemberByPersonAndOrgParams struct {
|
|
PersonID string `json:"person_id"`
|
|
OrgID string `json:"org_id"`
|
|
}
|
|
|
|
func (q *Queries) GetOrgMemberByPersonAndOrg(ctx context.Context, arg GetOrgMemberByPersonAndOrgParams) (OrgMember, error) {
|
|
row := q.db.QueryRowContext(ctx, getOrgMemberByPersonAndOrg, arg.PersonID, arg.OrgID)
|
|
var i OrgMember
|
|
err := row.Scan(
|
|
&i.OrgMemberID,
|
|
&i.OrgID,
|
|
&i.PersonID,
|
|
&i.RoleID,
|
|
&i.Status,
|
|
&i.JoinedAt,
|
|
&i.RemovedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getOrgMembersByOrgID = `-- name: GetOrgMembersByOrgID :many
|
|
SELECT om.org_member_id, om.org_id, om.person_id, om.role_id, om.status, om.joined_at, om.removed_at, om.created_at, om.updated_at, p.display_name, p.primary_email, r.role_name
|
|
FROM organization.org_members om
|
|
JOIN identity.persons p ON p.person_id = om.person_id
|
|
JOIN organization.roles r ON r.role_id = om.role_id
|
|
WHERE om.org_id = $1
|
|
ORDER BY p.display_name
|
|
`
|
|
|
|
type GetOrgMembersByOrgIDRow struct {
|
|
OrgMemberID string `json:"org_member_id"`
|
|
OrgID string `json:"org_id"`
|
|
PersonID string `json:"person_id"`
|
|
RoleID string `json:"role_id"`
|
|
Status string `json:"status"`
|
|
JoinedAt time.Time `json:"joined_at"`
|
|
RemovedAt sql.NullTime `json:"removed_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DisplayName string `json:"display_name"`
|
|
PrimaryEmail string `json:"primary_email"`
|
|
RoleName string `json:"role_name"`
|
|
}
|
|
|
|
func (q *Queries) GetOrgMembersByOrgID(ctx context.Context, orgID string) ([]GetOrgMembersByOrgIDRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, getOrgMembersByOrgID, orgID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []GetOrgMembersByOrgIDRow{}
|
|
for rows.Next() {
|
|
var i GetOrgMembersByOrgIDRow
|
|
if err := rows.Scan(
|
|
&i.OrgMemberID,
|
|
&i.OrgID,
|
|
&i.PersonID,
|
|
&i.RoleID,
|
|
&i.Status,
|
|
&i.JoinedAt,
|
|
&i.RemovedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DisplayName,
|
|
&i.PrimaryEmail,
|
|
&i.RoleName,
|
|
); 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
|
|
}
|