[Fix] Test DB keeps stale partial-index predicates after push - #1897
Open
mrubens wants to merge 1 commit into
Open
[Fix] Test DB keeps stale partial-index predicates after push#1897mrubens wants to merge 1 commit into
mrubens wants to merge 1 commit into
Conversation
drizzle-kit push does not detect WHERE-predicate changes on expression indexes, so persistent test databases kept the pre-#1779 version of task_runs_launch_idempotency_key_unique (missing canceled_at IS NULL) and failed the snapshot-resume retry test with a duplicate-key error. Run a reconcile pass after db:push:test that recreates predicate-bearing indexes whose live definition has drifted from schema.ts.
Contributor
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.
Problem
The enqueue-task test "allows retrying a resume that was canceled before queue publication" fails against a persistent
roomote_testdatabase with:#1779 added
AND canceled_at IS NULLto that index's predicate (migration0067_clean_storm.sql) so canceled runs release their launch idempotency key. Real databases pick that up via migrations, but the test database is synced exclusively throughdrizzle-kit push, which cannot detect WHERE-predicate changes on expression indexes: it reports "Changes applied" while leaving the old index in place. Any test DB created before #1779 keeps the stale predicate, so the canceled run still blocks the retry insert.Fix
packages/db/scripts/reconcile-test-indexes.ts: after push, recreate predicate-bearing expression indexes whose livepg_indexes.indexdefis missing the expected predicate fragments (currently the launch-idempotency and Discord source-event unique indexes).db:push:test, sopnpm test,infra:up, anddb:upself-heal a drifted test database.The script guards with
assertSafeTestDatabaseUrl, so it refuses to run against anything but a localhost test database.Verification
pnpm --filter @roomote/db db:push:testlogsRecreated task_runs_launch_idempotency_key_unique (was stale).packages/cloud-agents/src/server/__tests__/enqueue-task.test.tsthen passes twice consecutively (69 tests per run).