New table public.model_provider_keys (label, encrypted key, enabled,
optional concurrency limit). The migration copies each provider's
existing key into one row labelled 默认 and keeps
model_providers.encrypted_api_key as a mirror of the first enabled key,
so an older web image, the publish and rollback checks and the
connection-test hash keep working. Writes go through security-definer
functions gated by models.write and audited without key material; the
last enabled key of an enabled provider cannot be disabled or deleted.
admin_runtime gets the SELECT grant together with its SELECT policy
(BUG-147).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq