Files
member-console/internal/organization/organizations.sql.go
Christian Galo f23a84999c sqlc: standardize generated type names across all modules
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).
2026-04-05 02:35:36 -05:00

162 lines
3.7 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: organizations.sql
package organization
import (
"context"
)
const createOrganization = `-- name: CreateOrganization :one
INSERT INTO organization.organizations (name, slug, org_type, owner_person_id)
VALUES ($1, $2, $3, $4)
RETURNING org_id, name, slug, org_type, owner_person_id, status, created_at, updated_at
`
type CreateOrganizationParams struct {
Name string `json:"name"`
Slug string `json:"slug"`
OrgType string `json:"org_type"`
OwnerPersonID string `json:"owner_person_id"`
}
func (q *Queries) CreateOrganization(ctx context.Context, arg CreateOrganizationParams) (Organization, error) {
row := q.db.QueryRowContext(ctx, createOrganization,
arg.Name,
arg.Slug,
arg.OrgType,
arg.OwnerPersonID,
)
var i Organization
err := row.Scan(
&i.OrgID,
&i.Name,
&i.Slug,
&i.OrgType,
&i.OwnerPersonID,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getOrganizationByID = `-- name: GetOrganizationByID :one
SELECT org_id, name, slug, org_type, owner_person_id, status, created_at, updated_at FROM organization.organizations
WHERE org_id = $1
`
func (q *Queries) GetOrganizationByID(ctx context.Context, orgID string) (Organization, error) {
row := q.db.QueryRowContext(ctx, getOrganizationByID, orgID)
var i Organization
err := row.Scan(
&i.OrgID,
&i.Name,
&i.Slug,
&i.OrgType,
&i.OwnerPersonID,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getOrganizationBySlug = `-- name: GetOrganizationBySlug :one
SELECT org_id, name, slug, org_type, owner_person_id, status, created_at, updated_at FROM organization.organizations
WHERE slug = $1
`
func (q *Queries) GetOrganizationBySlug(ctx context.Context, slug string) (Organization, error) {
row := q.db.QueryRowContext(ctx, getOrganizationBySlug, slug)
var i Organization
err := row.Scan(
&i.OrgID,
&i.Name,
&i.Slug,
&i.OrgType,
&i.OwnerPersonID,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getOrganizationsByOwner = `-- name: GetOrganizationsByOwner :many
SELECT org_id, name, slug, org_type, owner_person_id, status, created_at, updated_at FROM organization.organizations
WHERE owner_person_id = $1
ORDER BY name
`
func (q *Queries) GetOrganizationsByOwner(ctx context.Context, ownerPersonID string) ([]Organization, error) {
rows, err := q.db.QueryContext(ctx, getOrganizationsByOwner, ownerPersonID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Organization{}
for rows.Next() {
var i Organization
if err := rows.Scan(
&i.OrgID,
&i.Name,
&i.Slug,
&i.OrgType,
&i.OwnerPersonID,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
); 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
}
const listOrganizations = `-- name: ListOrganizations :many
SELECT org_id, name, slug, org_type, owner_person_id, status, created_at, updated_at FROM organization.organizations
ORDER BY name
`
func (q *Queries) ListOrganizations(ctx context.Context) ([]Organization, error) {
rows, err := q.db.QueryContext(ctx, listOrganizations)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Organization{}
for rows.Next() {
var i Organization
if err := rows.Scan(
&i.OrgID,
&i.Name,
&i.Slug,
&i.OrgType,
&i.OwnerPersonID,
&i.Status,
&i.CreatedAt,
&i.UpdatedAt,
); 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
}