Files
T
cgalo5758 8d05934e93 Add domains registry with claims and placements
Domain names become an allocatable resource with one authority. A new
core module (schema `domains`, own migration stream between core and the
integrations) owns claims — a DNS node plus its whole subtree, mutually
disjoint: operator shared-domain roots, member claims carved from them,
and bring-your-own names proven by TXT verification — and placements,
which bind a name inside a claim to a provider slug and resource ref.

Verification moves to the claim and decouples from creation. A member
proves control of a domain once; afterwards every name inside it places
instantly, wildcard-CNAME friendly, with no further DNS work. The claim
workflow activates the claim and stops — it no longer creates a site —
so the sites list offers a one-click create once a domain verifies.

/domains/ask answers from placements and is registered by core rather
than the FedWiki adapter; its HTTP contract is unchanged. A configured
`domains-ask-fallback-url` forwards names the registry does not know to
a legacy answerer, the strangler seam wiki.cafe's migration needs; a
name the registry knows but has archived is refused locally.

FedWiki's create saga reserves the name before the farm call, carrying a
workflow-minted site id so retries are idempotent, and compensates on
failure. Sync places only names it owns, never stealing a member's;
lifecycle transitions and the retention purge maintain servability. An
unconditional boot pass seeds operator roots, releases orphaned
placements, and adopts pre-existing sites — grandfathering member-owned
external domains shortest-name-first, and skipping name policy, so a
live single-letter site cannot lose its certificate.

Members manage domains at /domains: claims with verification status, DNS
records including an optional wildcard row, check-now, cancel, release.
Name policy (reserved, blocked, premium, plus a single-letter guard) is
operator data; refusals collapse to a plain "unavailable" so the console
never becomes an oracle for who holds what.

BREAKING (pre-release): `fedwiki.custom_domain_verifications` and
`sites.is_custom_domain` are dropped, the flag now derived from the
placement's claim kind; resource key `fedwiki_custom_domains` migrates
to the platform-owned `external_domain_claims`; running
verify-custom-domain workflows must be terminated before deploy.
2026-07-24 21:25:40 -05:00

124 lines
5.8 KiB
YAML

version: "2"
sql:
- engine: "postgresql"
schema:
- "../../../db/migrations/"
# Registry tables: fedwiki queries derive is_custom_domain by joining
# domains.placements -> domains.claims (schema order mirrors the
# migration stream order, core -> domains -> fedwiki).
- "../../../domains/migrations/"
- "migrations/"
- "../../../db/sqlc_schemas.sql"
queries: "queries/"
gen:
go:
package: "fedwiki"
out: "."
sql_package: "database/sql"
emit_json_tags: true
emit_prepared_queries: false
emit_interface: true
emit_exact_table_names: false
emit_empty_slices: true
omit_unused_structs: true
rename:
fedwiki_custom_domain_verification: CustomDomainVerification
fedwiki_custom_domain_verifications: CustomDomainVerification
fedwiki_site: Site
fedwiki_sites: Site
# Registry spillover, pulled in by ../../../domains/migrations/.
# Pinned to their default-computed names so a later join that
# starts emitting these models cannot silently rename them.
domains_claim: DomainsClaim
domains_claims: DomainsClaim
domains_placement: DomainsPlacement
domains_placements: DomainsPlacement
domains_name_rule: DomainsNameRule
domains_name_rules: DomainsNameRule
core_organization: Organization
core_organizations: Organization
core_workspace: Workspace
core_workspaces: Workspace
core_role: Role
core_roles: Role
core_role_assignment: RoleAssignment
core_role_assignments: RoleAssignment
core_org_member: OrgMember
core_org_members: OrgMember
core_org_type: OrganizationOrgType
core_org_types: OrganizationOrgType
# Spillover tables pulled in because ../db/migrations/ declares the
# whole "core" schema. Renamed to match the exact pre-consolidation
# type names (from their old owning schema) so model diffs stay
# schema-string-only -- see internal/integration/sqlc.yaml for the
# canonical mapping this list is drawn from.
core_person: IdentityPerson
core_persons: IdentityPerson
core_user: IdentityUser
core_users: IdentityUser
core_account: BillingAccount
core_accounts: BillingAccount
core_entitlement_set: EntitlementsEntitlementSet
core_entitlement_sets: EntitlementsEntitlementSet
core_entitlement_set_rule: EntitlementsEntitlementSetRule
core_entitlement_set_rules: EntitlementsEntitlementSetRule
core_grant: EntitlementsGrant
core_grants: EntitlementsGrant
core_invoice: BillingInvoice
core_invoices: BillingInvoice
core_invoice_line_item: BillingInvoiceLineItem
core_invoice_line_items: BillingInvoiceLineItem
core_numeric_entitlement: EntitlementsNumericEntitlement
core_numeric_entitlements: EntitlementsNumericEntitlement
core_numeric_entitlement_contribution: EntitlementsNumericEntitlementContribution
core_numeric_entitlement_contributions: EntitlementsNumericEntitlementContribution
core_numeric_entitlement_usage: EntitlementsNumericEntitlementUsage
core_numeric_entitlement_usages: EntitlementsNumericEntitlementUsage
core_outbox: IntegrationOutbox
core_outboxes: IntegrationOutbox
core_payment: BillingPayment
core_payments: BillingPayment
core_payment_method: BillingPaymentMethod
core_payment_methods: BillingPaymentMethod
core_plan_ladder: BillingPlanLadder
core_plan_ladders: BillingPlanLadder
core_plan_ladder_tier: BillingPlanLadderTier
core_plan_ladder_tiers: BillingPlanLadderTier
core_pool_assignment: EntitlementsPoolAssignment
core_pool_assignments: EntitlementsPoolAssignment
core_pool_provision: EntitlementsPoolProvision
core_pool_provisions: EntitlementsPoolProvision
core_pool_provision_ladder: EntitlementsPoolProvisionLadder
core_pool_provision_ladders: EntitlementsPoolProvisionLadder
core_pool_provision_transition: EntitlementsPoolProvisionTransition
core_pool_provision_transitions: EntitlementsPoolProvisionTransition
core_price: BillingPrice
core_prices: BillingPrice
core_product: BillingProduct
core_products: BillingProduct
core_product_kind: BillingProductKind
core_product_kinds: BillingProductKind
core_provider: Provider
core_providers: Provider
core_provider_operation: ProviderOperation
core_provider_operations: ProviderOperation
core_provider_state: IntegrationProviderState
core_provider_states: IntegrationProviderState
core_resource_key: ResourceKey
core_resource_keys: ResourceKey
core_resource_pool: EntitlementsResourcePool
core_resource_pools: EntitlementsResourcePool
core_subscription: BillingSubscription
core_subscriptions: BillingSubscription
core_subscription_change: BillingSubscriptionChange
core_subscription_changes: BillingSubscriptionChange
core_subscription_item: BillingSubscriptionItem
core_subscription_items: BillingSubscriptionItem
core_subscription_scheduled_change: BillingSubscriptionScheduledChange
core_subscription_scheduled_changes: BillingSubscriptionScheduledChange
core_webhook_event: IntegrationWebhookEvent
core_webhook_events: IntegrationWebhookEvent
overrides:
- db_type: "uuid"
go_type: "string"