Title: chore(coderd/database): drop deferred chat spend and cost columns · Issue #27600 · coder/coder · GitHub
Open Graph Title: chore(coderd/database): drop deferred chat spend and cost columns · Issue #27600 · coder/coder
X Title: chore(coderd/database): drop deferred chat spend and cost columns · Issue #27600 · coder/coder
Description: Context The chat-cost stack (#27328, #27329, #27330) removed native chat usage limits and native chat cost tracking, leaving AI Gateway data and budgets as the only path. Three physical columns, one table, and one index were deliberately...
Open Graph Description: Context The chat-cost stack (#27328, #27329, #27330) removed native chat usage limits and native chat cost tracking, leaving AI Gateway data and budgets as the only path. Three physical columns, on...
X Description: Context The chat-cost stack (#27328, #27329, #27330) removed native chat usage limits and native chat cost tracking, leaving AI Gateway data and budgets as the only path. Three physical columns, on...
Opengraph URL: https://github.com/coder/coder/issues/27600
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"chore(coderd/database): drop deferred chat spend and cost columns","articleBody":"## Context\n\nThe chat-cost stack (#27328, #27329, #27330) removed native chat usage limits and native chat cost tracking, leaving AI Gateway data and budgets as the only path. Three physical columns, one table, and one index were deliberately left in place for one release so a replica still running the previous release keeps working during a rolling upgrade.\n\n`users.sql` and `groups.sql` use `SELECT *`, so sqlc bakes every column into explicit column lists in `GetUserByID`, `GetUserByEmailOrUsername`, `GetUsersByIDs`, `GetGroupByID`, `GetGroupByOrgAndName`, and `GetGroups`. Dropping the `users` and `groups` columns in the same release would have failed broad authorization, audit, and API-key reads on an old replica, not just the usage-limit admin screens. Dropping `chat_messages.total_cost_micros` would have broken `InsertChatMessages`, and therefore every chat message insert.\n\n`chat_usage_limit_config` and `idx_chat_messages_owner_spend` were kept for the same reason: an old replica still serves `getMyChatUsageLimitStatus`, which reads that table through `chatd.ResolveUsageLimitStatus` and runs `GetUserChatSpendInPeriod` behind that index. Dropping the table would 500 that handler (it tolerates only `sql.ErrNoRows`); dropping the index would leave a per-minute-polled path scanning `chat_messages`.\n\nNothing in the application reads any of these as of #27330.\n\n## Scope\n\nDrop in a single migration:\n\n- [ ] `users.chat_spend_limit_micros` and `users_chat_spend_limit_micros_check`\n- [ ] `groups.chat_spend_limit_micros` and `groups_chat_spend_limit_micros_check`\n- [ ] `chat_messages.total_cost_micros`\n- [ ] `chat_usage_limit_config` (table, plus its sequence and three check constraints)\n- [ ] `idx_chat_messages_owner_spend`\n\nThen:\n\n- [ ] Delete the two `\"chat_spend_limit_micros\": ActionTrack` entries in `enterprise/audit/table.go` (the `&database.User{}` and `&database.AuditableGroup{}` maps). They exist only because `entry()` exits the process at package init for any JSON-tagged field without an action, so they must go with the columns.\n- [ ] Remove the `&i.ChatSpendLimitMicros` scan from `GetAuthorizedUsers` in `coderd/database/modelqueries.go`, which is hand-maintained and must match generated `GetUsers`.\n- [ ] `make gen`, then confirm `check_constraint.go` loses both check constants and the three `chat_usage_limit_config` ones, `unique_constraint.go` loses its primary key, and `models.go` loses both fields and the now-unused `ChatUsageLimitConfig` struct.\n- [ ] Deleting a migration does not invalidate the mtime-gated `dump.sql` target, so if the drop is ever reverted, `touch` a migration that creates the object before regenerating.\n\n## Notes\n\n- Choose the migration number at authoring time against `origin/main`, not now. Also note that stacked PRs target their parent branch, so a duplicate migration number passes CI green; compare against `origin/main` directly before pushing.\n- Operators who still want their old native caps should read these columns out of the database before this lands. #27329 did not migrate configured values into `group_ai_budgets`: period semantics do not map (native supported day/week/month, gateway budgets are month-only), group resolution picks the highest budget where native limits took the minimum, and `user_ai_budget_overrides.group_id` is `NOT NULL` so a groupless native user override has no destination.\n\n> Mux filed this issue on Mike's behalf.\n\n","author":{"url":"https://github.com/ibetitsmike","@type":"Person","name":"ibetitsmike"},"datePublished":"2026-07-28T16:49:18Z","url":"https://github.com/coder/coder/issues/27600"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:784fc360-a033-e3cc-6641-cb9ea7d63659 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C996:2AAD2E:189E35A:20D8EC9:6B014E6A |
| html-safe-nonce | 8ef5d7cb45b492886867e8ba4f22f11600779382ff98f07f70820884ec4f276e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTk2OjJBQUQyRToxODlFMzVBOjIwRDhFQzk6NkIwMTRFNkEiLCJ2aXNpdG9yX2lkIjoiNzY0NjE0NjQyODQ5Mzk3NTE0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ccaa08e10e51d1a27cc3fa4e790505fa0e7cc35c078fc71a1acda2e5b0cda392 |
| hovercard-subject-tag | issue:5001002207 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/27600/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d8bb69e5d500edce80cc14c8643fb3afc220f76aca3a43c0f27b9f50d1f9eb38/coder/coder/issues/27600 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d8bb69e5d500edce80cc14c8643fb3afc220f76aca3a43c0f27b9f50d1f9eb38/coder/coder/issues/27600 |
| og:image:alt | Context The chat-cost stack (#27328, #27329, #27330) removed native chat usage limits and native chat cost tracking, leaving AI Gateway data and budgets as the only path. Three physical columns, on... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ibetitsmike |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width