Skip to content

fix(knowledge): retry the Tin projection after a database refuses the extension - #8039

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/tin-migration-defer
Sep 20, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/tin-migration-defer

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • A script migration can defer: up throws ScriptMigrationDeferred, the runner logs it, leaves the name unrecorded, and continues with the remaining migrations
  • The Tin keyword projection defers when the database offers tin but refuses CREATE EXTENSION, so the next upgrade after the extension is permitted installs it — previously the refusal was recorded as applied and never retried
  • Corrects the searchIndexBases comment: is_search_index is only ever turned on (legacy adoption), so a stale cached false just keeps that base on the GIN projection for one TTL

Type of Change

  • Bug fix

Testing

Tested manually. New unit tests cover the deferral (both refusal codes), the unavailable-extension no-op, and that any other extension error still fails the migration; a runner test asserts a deferred migration is not recorded and does not fail the upgrade. Verified each new test fails without its fix. bun run lint, bun run check:audits (47 audits), packages/db type-check and its full vitest suite pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 20, 2026 4:41am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/db/script-migrations/0019_tin_keyword_projection.ts
@greptile-apps

greptile-apps Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the prior direct-execution and continuation gaps are fixed, and no new actionable defects remain.

Summary

This PR makes an unavailable-permission Tin installation retryable without failing an upgrade or the direct development adoption path.

  • Adds a dedicated deferral signal that leaves the migration unrecorded while allowing subsequent migrations to run.
  • Treats extension refusal as a direct-adoption no-op while preserving failures for unrelated database errors.
  • Adds coverage for refusal codes, unavailable extensions, direct execution, unrecorded deferrals, and continuation to later migrations.
  • Clarifies the search-index cache comment to reflect one-way legacy adoption behavior.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Run Tin migration] --> B{Tin listed as available?}
    B -- No --> C[Record migration as completed no-op]
    B -- Yes --> D[CREATE EXTENSION tin]
    D -->|Success| E[Install and backfill projection]
    E --> F[Build index and record migration]
    D -->|Permission or feature refusal| G[Throw ScriptMigrationDeferred]
    G --> H{Registered runner?}
    H -- Yes --> I[Leave unrecorded and continue]
    H -- Direct adoption --> J[Log warning and keep GIN fallback]
    D -->|Other error| K[Fail operation]
Loading

Reviews (2) · Last reviewed commit: "fix(db): keep a deferred Tin projection ..."

Comment thread packages/db/script-migrations/0019_tin_keyword_projection.ts
Comment thread packages/db/script-migrations/index.test.ts Outdated
Comment thread packages/db/script-migrations/index.ts
… extension

A script migration can now defer: `up` throws `ScriptMigrationDeferred`, the runner
logs it, leaves the name unrecorded and runs the remaining migrations. The Tin
projection defers when the database offers `tin` but refuses to create it, so the
upgrade after the extension is permitted installs it instead of skipping it forever.
`db:push` runs the migration file directly, where a deferral has no
migration record to leave unwritten, so a refused extension aborted the
push. The direct entry point now adopts the projection where the database
allows it and logs the refusal otherwise, while the registered runner
still sees the deferral. Also covers continuation after a deferral with a
synthetic migration list, which the registry cannot express while the only
deferring migration is its last entry.
@waleedlatif1
waleedlatif1 force-pushed the fix/tin-migration-defer branch from 78fcb4c to 87dd2ca Compare September 20, 2026 04:39
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 751887f into staging Sep 20, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/tin-migration-defer branch September 20, 2026 04:58

This branch was successfully deployed

1 active deployment
Preview 87dd2ca7 Deployed Sep 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant