Repository navigation
feat: keep Coder Agents tables in a chatd schema - #1
Merged
Merged
Conversation
Fork migrations are nodes named by UUID with explicit parents. UpAll runs upstream's numbered migrations one version at a time and applies every ready node before each step. The adopt node moves the Coder Agents tables, views, sequences, enums and functions from public to chatd. Every connection adds chatd to the search path. Adds fork-ci and fork-sync workflows. See coderd/database/migrations/chatdmig/README.md.
Every migration transaction, core or chatd node, sets lock_timeout (5s by default) and retries after a lock timeout or deadlock, so a migration that waits for a long transaction no longer stalls every query on the table. UpAll commits each core version and node on its own, on purpose now: locks last for one migration, and a restart continues where it stopped. Fork nodes get three header options: "-- phase: background" runs a node after the server starts, "-- repeat: until-no-rows" runs a bounded batch in its own transaction until it changes nothing, and "-- transaction: none" runs one statement outside a transaction for CREATE INDEX CONCURRENTLY, with a check for invalid indexes. coder server calls ServerMigrate, which starts the background runner after the startup migrations. fork-ci starts Postgres with max_connections=1000 and accepts a pg_dump newer than 16.
TestRoutingMatchesUpstream routes every migration after 634 again. Without the override files, a synced mixed migration fails the schema job even after its override is written.
This was referenced Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keeps the Coder Agents tables in their own
chatdPostgres schema, with fork migrations named by UUID and ordered by their parents. Upstream's numbered migrations still run inpublic, somaincan merge upstream every day. Design, sync flow and how to add a fork migration:coderd/database/migrations/chatdmig/README.md.Changes
coderd/database/migrations/chatdmig: the graph (routes.txt,nodes/,override/), the runner and its ledgerchatd.migration_nodes, the route classifier, and thechatdmigtool (route,new,check).publictochatdwithSET SCHEMA. No row is copied.coder servermigrates withmigrations.ServerMigrate: core moves one version at a time, and every ready node runs before each step, under one advisory lock.EnsureCleanAllalso checks the graph.chatdon the search path (WithChatdSearchPath). Upstream files change in 7 lines: 3 incli/server.go, 3 indbtestutil/postgres.goand 1 in its test..github/workflows/fork-ci.yaml(graph, schema, chat-tests, build) andfork-sync.yaml(daily upstream merge through a self-merging PR; disables upstream workflows).Migration locking
coder-local rollbackdoes.lock_timeout(5 s) and retries after a lock timeout or deadlock, up to 10 attempts. A migration that waits for a long transaction no longer stalls every query on the table.-- phase: backgroundruns after the server starts,-- repeat: until-no-rowsruns a bounded batch per transaction until it changes nothing, and-- transaction: noneruns one statement outside a transaction forCREATE INDEX CONCURRENTLY, with a check for the invalid index that a failed build leaves.Validation
go test ./coderd/database/migrations/chatdmig/with Postgres: the routed graph gives upstream's schema apart from the schema name, and an upgrade from 634 or from the split equals a fresh database.userscolumn, achatscolumn and index, a new chat table, one that touches both, and one that creates tables in both schemas) route as core, chatd, chatd, core and mixed. With an override for the mixed one, every chatdmig test passes and each object lands in the expected schema../coderd/database/...and./coderd/x/...pass, apart fromTestPubsub_Disconnect, which needs the Docker socket. In./cli, all 57 subtests ofTestServerandTestConnectToPostgrespass (built-in Postgres skipped, since the container runs as root). The package then fails a goleak check on HTTP/2 client goroutines; baseb798061108fails the same way. The 242 chat, skill and MCP tests of./coderdand./enterprise/coderdpassed on the first commit.UpAlltook 54 ms, kept every row, and its schema dump equals a freshUpAll.actionlintandshellcheckare clean.Before merge
FORK_SYNC_TOKENsecret.mainruleset requires its four checks.Merging deploys nothing until the autodeploy LaunchAgent is loaded.