Skip to content

feat(coderd/database): add organization AI model config table - #30717

Merged
SasSwart merged 6 commits into
mainfrom
sdlcgraph/aigov-612-2-schema
Oct 21, 2026
Merged

SasSwart merged 6 commits into
mainfrom
sdlcgraph/aigov-612-2-schema

Conversation

@SasSwart

@SasSwart SasSwart commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Adds ai_model_configs: an organization's AI Governance configuration for one model on one configured provider. Token prices are its first settings. Migration 000630 is additive and needs no backfill.

  • Rows are soft deleted with a deleted flag. A surrogate id is the primary key, and a partial unique index allows one live row per (organization_id, provider_id, model). Cascades on delete of the organization or provider. The organization is a column, as in other organization-scoped tables.
  • A check constraint rejects an empty model.
  • Pricing per provider ID is what lets openai-compat gateways be priced, and lets providers of the same type have different prices.
  • Site-wide prices per provider type stay in the existing ai_model_prices table, unchanged.

Recording which price was used on each token usage record is deferred until its design settles.

Used later: #30718 adds the queries that read and write the table, and #30719 looks prices up from it. The rest of the diff is generated.


This PR was generated by Coder Agents on behalf of @SasSwart.

@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

AIGOV-612

@SasSwart SasSwart left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self Review

Comment thread coderd/database/dump.sql Resolved
@SasSwart
SasSwart marked this pull request as ready for review October 15, 2026 07:21
@SasSwart
SasSwart force-pushed the sdlcgraph/aigov-612-2-schema branch from 637482c to cb64491 Compare October 15, 2026 11:12
@SasSwart SasSwart changed the title feat(coderd/database): add organization AI model price tables feat(coderd/database): add organization AI model price table Oct 15, 2026
@SasSwart
SasSwart requested a review from ssncferreira October 15, 2026 13:28

@ssncferreira ssncferreira left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, just making sure the table is named for AI Governance configs, not just for prices.
Also, a reminder to rebase on main and update the database migration number

@SasSwart
SasSwart force-pushed the sdlcgraph/aigov-612-2-schema branch from cb64491 to b2f850f Compare October 16, 2026 10:22
@SasSwart SasSwart changed the title feat(coderd/database): add organization AI model price table feat(coderd/database): add organization AI model config table Oct 16, 2026
@SasSwart
SasSwart requested a review from mtojek October 19, 2026 08:02
@SasSwart
SasSwart force-pushed the sdlcgraph/aigov-612-2-schema branch from b2f850f to 1ccb8d9 Compare October 19, 2026 08:56
Base automatically changed from sdlcgraph/aigov-612-1-price-validation to main October 19, 2026 09:12
@SasSwart
SasSwart force-pushed the sdlcgraph/aigov-612-2-schema branch from 1ccb8d9 to 3cd08f7 Compare October 19, 2026 09:12
Organization prices are only per configured provider. Site-wide prices
per provider type stay in ai_model_prices.
Drop the ai_model_price_kind enum and the price_* columns on
aibridge_token_usages until the design is settled.
… config

Rename ai_org_provider_model_prices to ai_model_configs, so the table can
hold other per-model AI Governance settings next to token prices. The
organization stays a column, as in other organization-scoped tables.

Reject an empty model with a check constraint.
…to 000630

Main already uses 000623 through 000629.
Add a deleted flag to ai_model_configs. A surrogate id becomes the
primary key, and a partial unique index keeps one live row per
organization, provider and model, so a soft-deleted row does not block a
new one for the same model.
@SasSwart
SasSwart force-pushed the sdlcgraph/aigov-612-2-schema branch from 5db6ac8 to 6a6460c Compare October 21, 2026 05:39
@SasSwart
SasSwart merged commit d14631d into main Oct 21, 2026
29 checks passed
@SasSwart
SasSwart deleted the sdlcgraph/aigov-612-2-schema branch October 21, 2026 06:17
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants