Files
member-console/internal/entitlements/queries/resource_keys.sql
T
cgalo5758 dd3962990b Adopt entity keys and add invoice numbers
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.
2026-08-29 20:12:04 -05:00

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;