Repository navigation
feat(postgres): allow migration-managed schemas - #913
Merged
Merged
Conversation
Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Probe tables, privileges, and sequence usage when autoCreateSchema is false, so connect() rejects with a descriptive error instead of the first message failing - Export postgresSchemaStatements as the single source of the adapter DDL, used by ensureSchema(), the tests, and migration tooling - Compare the README and docs migration SQL to postgresSchemaStatements in the unit tests - Run the integration suite as a non-superuser admin by granting membership in the runtime role, and pin search_path on the admin pool - Declare POSTGRES_TEST_URL in turbo.json globalEnv - List autoCreateSchema in the chat/adapters catalog entry - Document ALTER ROLE ... SET search_path as the pooler-safe way to target a dedicated schema, and the postgresSchemaStatements export - Update state-pg AGENTS.md test prerequisites and schema release rules Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
- Check SELECT, INSERT, and DELETE on every table, and UPDATE only on locks, cache, and lists, since subscriptions and queues are never updated - Accept nextval through either USAGE or UPDATE on the list and queue sequences, and skip the sequence check for identity columns - Run the integration suite under least-privilege grants and add an identity-column schema test - Assert the probe's per-table privileges in the unit tests - Describe the exact privileges connect() verifies in the README, docs, and AGENTS.md Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
bensabic
enabled auto-merge (squash)
September 8, 2026 07:47
dancer
approved these changes
Sep 9, 2026
patrick-chinchill
added a commit
to Chinchill-AI/chat-sdk-python
that referenced
this pull request
Sep 30, 2026
…ion-owned schemas (#240) PostgresStateAdapter.set_if_not_exists now uses upstream's conditional upsert (ON CONFLICT DO UPDATE ... WHERE expires_at <= now() RETURNING), so expired dedupe/lease rows are reclaimed atomically; live and permanent rows are never overwritten. Ports upstream d88789c9 (vercel/chat#636, chat@4.35.0) and ea025af7 (vercel/chat#913, chat@4.41.0). New opt-in auto_create_schema=False (keyword-only; default True) skips DDL and runs a read-only table/privilege/sequence probe, raising chat_sdk.StateSchemaError on a missing table or grant. New exports: POSTGRES_SCHEMA_STATEMENTS, StateSchemaError; README documents the migration SQL. Divergences (docs/UPSTREAM_SYNC.md): StateSchemaError(ChatError) instead of plain Error; connect() serialized on an asyncio.Lock (queued callers retry); adapter-owned asyncpg pool closed on a failed connect() to avoid leaking 10 connections per retry. Consumer impact: Postgres-backed dedupe and leases recover after expiry without cleanup; no schema change; defaults unchanged. Tests: mock pool no longer reclaims under DO NOTHING; injectable mock clock; opt-in live suite via POSTGRES_TEST_URL. Closes #240
This branch was successfully deployed
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.
Adds
autoCreateSchema: falseso applications can manage PostgreSQL tables and indexes through migrations and run the bot with restricted database permissions.Automatic schema creation remains enabled by default. The docs include the migration SQL and required grants. The expired-cache behavior reported in the issue is already fixed in the base branch.
Closes #722