Expand description
Database access layer for the SaaS domain management module.
All queries run against the schema defined in
migrations/20240115000001_saas_domains.sql. Queries use runtime sqlx
(query/query_as) rather than the compile-time-checked macros so the
crate builds without a live database connection.
Functions§
- check_
domain_ quota - Return
(current_domain_count, max_domains)for a tenant. - create_
api_ key - Insert a new API key row (the raw key is never stored, only its hash).
- create_
backend - Add a backend to an upstream.
- create_
domain - Insert a new domain and return it.
- create_
route - Create a route for a domain.
- create_
upstream - Create an upstream (and any backends supplied inline).
- create_
verification_ challenge - Record a verification challenge for a domain.
- delete_
api_ key - Delete an API key scoped to a tenant.
- delete_
backend - Delete a backend, verifying it belongs to the tenant’s upstream.
- delete_
domain - Delete a domain scoped to a tenant. Returns whether a row was removed.
- delete_
route - Delete a route scoped to a tenant.
- delete_
upstream - Delete an upstream scoped to a tenant.
- disable_
api_ key - Disable an API key without deleting it.
- disable_
domain - Disable a domain.
- domain_
exists - Check whether a domain is already registered (globally unique).
- enable_
api_ key - Re-enable a disabled API key.
- enable_
domain - Enable a domain.
- get_
api_ key_ for_ tenant - Fetch an API key scoped to a tenant.
- get_
domain_ for_ tenant - Fetch a domain scoped to a tenant.
- get_
route_ for_ tenant - Fetch a route scoped to a tenant.
- get_
tenant_ usage - Aggregate usage statistics for a tenant.
- get_
upstream_ for_ tenant - Fetch an upstream (with its backends) scoped to a tenant.
- is_
tenant_ active - Whether a tenant exists and is active.
- list_
api_ keys - List API keys for a tenant.
- list_
domains - List all domains for a tenant.
- list_
routes_ for_ domain - List routes for a domain, highest priority first.
- list_
upstreams - List upstreams (with backends) for a tenant.
- record_
verification_ attempt - Increment the verification attempt counter and stamp the attempt time.
- update_
last_ used - Stamp an API key’s last-used time (best-effort).
- update_
route - Apply a partial update to a route (only supplied fields change).
- update_
ssl_ status - Update a domain’s SSL status and optional expiry.
- update_
upstream - Apply a partial update to an upstream.
- update_
verification_ status - Update a domain’s verification status (stamping
verified_aton success). - validate_
api_ key_ by_ hash - Look up an API key by its hash, excluding expired keys.