Skip to content

fix(cli): stop skipping colliding schemas (CLI-2272) - #6394

Draft
7ttp wants to merge 2 commits into
developfrom
7ttp/drop-schemas-oid-collision
Draft

fix(cli): stop skipping colliding schemas (CLI-2272)#6394
7ttp wants to merge 2 commits into
developfrom
7ttp/drop-schemas-oid-collision

Conversation

@7ttp

@7ttp7ttp commented Aug 29, 2026

Copy link
Copy Markdown
Member

TL;DR

fixes db reset, db lint, db diff, and migration down silently skipping a user schema when its oid also appears in another catalog
which was caused by joining pg_depend on objid without the classid that scopes oids to a single catalog

now fixed by constraining the join to pg_catalog.pg_namespace rows in every copy of the query.
Resets now drop schemas that earlier versions silently skipped....

ref:

@7ttp7ttp self-assigned this Aug 29, 2026
@7ttp

7ttp commented Aug 30, 2026

Copy link
Copy Markdown
MemberAuthor

/ai-review

@github-actionsgithub-actionsBot 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.

Superseded by a newer AI review

🤖 AI Review

The core pg_depend fix is sound and consistently applied across all six SQL copies. Of Claude's six findings, five are confirmed: the underlying duplication remains, the drift guard omits the Go SQL files, its regression regex is brittle, its source unescaping is incomplete, and the unchanged advisors query has a related cross-catalog OID bug. The test-organization finding is refuted because the guarded modules share one invariant and trusted conventions do not require module-matched test filenames. Codex reported no findings. No major or critical issues were found.

Findings

SeverityLocationCategorySourcesClaim
🟡 MINORapps/cli/src/legacy/commands/db/shared/legacy-migra.deno-templates.unit.test.ts:65duplicationclaudeThe new equality tests preserve four hand-copied SQL literals instead of consolidating their shared SQL definitions.
🟡 MINORapps/cli-go/pkg/migration/queries/list.sql:6test-coverageclaudeThe new drift guard covers only the four TypeScript copies and does not protect the two changed Go SQL files from regressing to the unconstrained join.
🟡 MINORapps/cli/src/legacy/commands/db/advisors/advisors.lints-sql.ts:11correctnessclaudeThe advisors SQL has a related unconstrained pg_depend join that can hide an unindexed foreign key when an extension dependency from another catalog shares the table OID.
⚪ NITapps/cli/src/legacy/commands/db/shared/legacy-migra.deno-templates.unit.test.ts:59test-qualityclaudeThe unconstrained-join regex is formatting-sensitive and can reject a corrected multiline join or miss an unconstrained join followed by same-line text.
⚪ NITapps/cli/src/legacy/commands/db/shared/legacy-migra.deno-templates.unit.test.ts:49test-qualityclaudeextractSqlLiteral performs unnecessary and incomplete template-literal unescaping.

Findings outside the diff

  • 🟡 MINORapps/cli/src/legacy/commands/db/advisors/advisors.lints-sql.ts:11 — The advisors SQL has a related unconstrained pg_depend join that can hide an unindexed foreign key when an extension dependency from another catalog shares the table OID.
Refuted findings (kept for transparency, not posted as review comments)
  • apps/cli/src/legacy/commands/db/shared/legacy-migra.deno-templates.unit.test.ts:52 (test-organization): The schema-listing guard is misplaced because it tests unrelated modules from a file named for migra Deno templates.
    Refuted: The modules are related by the exact shared invariant under test, and the test is located in db/shared. The trusted testing guidance requires the .unit.test.ts project suffix but does not require every test filename to match one production module; the cited code-structure examples do not establish that rule.

Stats

Claude findings: 6 · Codex findings: 0 · Confirmed: 5 · Refuted: 1 · Uncertain: 0


Models: claude-opus-5 + gpt-5.6-sol · Trigger: manual · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment threadapps/cli-go/pkg/migration/queries/list.sql
Sign up for freeto 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.

db reset --linked silently skips a user schema when its OID collides with another catalog's OID (missing pd.classid)

1 participant

@7ttp