Replace the entity slugs on organizations, workspaces, resource pools, and plan ladders with nullable `key` columns and add keys to products, prices, and entitlement sets. Rename `providers.slug` to `provider` and add partial unique indexes for system and org role names. Assign invoice numbers per billing account from a gapless transactional counter; Stripe's number moves to the invoice mapping as an external reference. Seeds, fixtures, and the operator lookup address rows by key, and the returning-login resync no longer blanks a display name when the IdP sends no `name` claim.
21 lines
839 B
SQL
21 lines
839 B
SQL
-- name: ListResourceKeys :many
|
|
SELECT * FROM core.resource_keys
|
|
ORDER BY resource_key ASC;
|
|
|
|
-- name: GetResourceKey :one
|
|
-- Single-key lookup for the rule-authoring handler: rule_type is derived
|
|
-- server-side from the key's kind, never taken from client input.
|
|
SELECT * FROM core.resource_keys
|
|
WHERE resource_key = $1;
|
|
|
|
-- name: ListResourceKeyLabels :many
|
|
-- Display metadata for entitlement rendering: each key's human-friendly
|
|
-- label plus its owning integration's display name. LEFT JOIN because
|
|
-- provider NULL = platform-owned/pooled (see the resource_keys DDL
|
|
-- comment); such keys render un-attributed.
|
|
SELECT rk.resource_key, rk.display_name, rk.unit,
|
|
COALESCE(p.display_name, '') AS provider_display_name
|
|
FROM core.resource_keys rk
|
|
LEFT JOIN core.providers p ON p.provider = rk.provider
|
|
ORDER BY rk.resource_key ASC;
|