Skip to content

Database Migrations: scopes array + typed allow-list #19845

Description

@ThomasK33

Description

  • Migrate API keys from a single scope column to scopes api_key_scope[] and add allow_list text[] supporting entries like workspace:<uuid>, template:*, or *:*.
  • Default/backfill existing rows to scopes=['all'] and allow_list=['*:*'] to maintain backward compatibility.
  • Extend the existing api_key_scope enum with the new low-level scope names introduced in this RFC (e.g., workspace:read, template:read, api_key:create, etc.).

Key files/areas

  • SQL migrations in coderd/database/migrations/ (both up/down).
  • Generated models in coderd/database/models.go (via make gen).
  • Reference low-level scope names from coderd/rbac/policy/policy.go (RBACPermissions) when updating api_key_scope enum values.

Acceptance criteria

  • Running make gen succeeds; compiled models expose []APIKeyScope (or []string) and []string allow_list.
  • Existing installations upgrade without breaking token usage; no data loss.
  • Add a down migration returning to the old schema.
  • Enum updated with new low-level scope values when enum array is selected; down migration accounts for removed enum variants if needed.
  • api_key_scope enum includes all known <resource>:<action> from policy.RBACPermissions (public and internal). The public catalog exposed to users is a filtered subset defined in the low‑level catalog task; document how to update the enum when RBAC evolves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions