Skip to content

test(nextly): prove migrate:fresh discovery against a real postgres - #1745

Merged
mobeenabdullah merged 1 commit into
mainfrom
test/migrate-fresh-discovery-against-a-real-db
Sep 10, 2026
Merged

mobeenabdullah merged 1 commit into
mainfrom
test/migrate-fresh-discovery-against-a-real-db

Conversation

@mobeenabdullah

Copy link
Copy Markdown
Collaborator

Follows #1736, from a Codex P1 on its merged head. Test-only, so no changeset.

What the existing test could not see

The unit test asserts the rendered SQL contains to_regclass and quote_ident.
That is necessary and not sufficient: it stays green if the predicate is
inverted with <>, or joined with OR instead of AND. Both enumerate the
wrong relations, and this is a command that drops what it enumerates.

It is the failure AGENTS.md names — a property that returns green from the
broken implementation too, carrying the authority of having been checked. I
quoted that rule at someone else this morning and then shipped an instance of it.

The property that actually separates correct from broken is which rows come
back
, and only a database can answer that.

The fixture, built so each wrong answer shows

search_path is tenant, public, and four tables sit in three schemas:

table where must be returned because
shadowed tenant and public once two relations, one name; the drop reaches exactly one
tenant_only tenant yes reachable
public_only public yes reachable through the path's second entry
hidden_only a schema off the path no the drop cannot name it

public_only is the row that fails a current_schema() implementation — the
version I wrote first, and the one this PR's predecessor corrected. hidden_only
is the row that fails an inverted or OR-ed predicate. shadowed is the row
that fails a query returning every copy rather than the resolved one.

A fourth case asserts pg_class and pg_namespace never appear: pg_catalog is
on every search path implicitly, so relation visibility on its own admits it.

Session pinning

One pg.Client held for the file, because getDrizzle() wraps a Pool — a
SET search_path on a pooled connection binds to whichever client served it and
the reads may run on another. A first case asserts SHOW search_path really
contains the tenant schema, so a reset session fails as a fixture problem rather
than looking like a defect in the predicate.

Verification

Locally: typechecks, lints, 11,901 unit tests pass, and the file is collected
by vitest.integration.config.ts (4 tests, skipped for the documented missing-URL
reason) rather than silently excluded.

⚠️ The assertions have not executed here — no Docker or PostgreSQL is reachable
from this machine. The Postgres CI leg is the oracle. The sibling probe added in
#1721/#1727 uses this same shape and has since passed on all three dialects, so
the harness itself is proven even though these cases are new.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T22:54:48.886628Z 0ef3799 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c78b5771-797f-45bb-a48c-994213b46848

📥 Commits

Reviewing files that changed from the base of the PR and between 3aa8a9f and 0ef3799.

📒 Files selected for processing (1)
  • packages/nextly/src/cli/commands/__tests__/migrate-fresh-discovery.integration.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mobeenabdullah

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 0ef3799cf1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

Whole-Repository Code Hygiene Summary

Full dead-code, duplication, and complexity report for the PR branch as it stands now. Playground is excluded. Quality gate enforcement on introduced issues is performed by the Changed files job.

🌿 Fallow

Warning

Review needed

⚠️ 73 code issues · ⚠️ 694 clone groups · ⚠️ 1046 health findings

See inline review comments for per-finding details.

Code issues (73)
Category Count
Unused files 2
Unused exports 5
Unused dependencies 19
Unused devDependencies 6
Unresolved imports 2
Unlisted dependencies 1
Circular dependencies 38
Duplication (694 groups · 29077 lines · 4.1%)
Locations Lines Tokens
schemas/_dialect-bundles/mysql.relations.ts:40-134
schemas/_dialect-bundles/postgres.relations.ts:40-134
schemas/_dialect-bundles/sqlite.relations.ts:40-134
95 593
cli/commands/db-sync-demote.ts:70-75
cli/commands/db-sync-promote.ts:38-43
cli/commands/dev-build.ts:100-105
cli/commands/dev-build.ts:179-184
cli/commands/dev-build.ts:299-304
cli/commands/dev-build.ts:411-416
cli/commands/dev-build.ts:552-557
cli/commands/dev-server.ts:575-580
cli/commands/dev-server.ts:840-845
cli/commands/dev-server.ts:1143-1148
cli/commands/migrate-field-groups.ts:110-115
6 70
entries/EntryList/EntryTableSkeleton.tsx:74-98
collection/components/CollectionTableSkeleton.tsx:94-118
field-group/components/FieldGroupTableSkeleton.tsx:90-114
plugins/components/PluginsTableSkeleton.tsx:86-110
singles/components/SinglesTableSkeleton.tsx:77-101
src/components/table-skeleton.tsx:100-124
25 89
collections/config/validate-config.ts:380-433
field-groups/config/validate-field-group.ts:185-238
singles/config/validate-single.ts:190-243
54 152
dispatcher/handlers/collection-dispatcher.ts:922-964
field-groups/services/field-group-table-provisioning.ts:186-236
singles/services/reconcile-single-companion.ts:110-160
51 149

… and 689 more groups.

Across 423 files.

Complexity (1046 functions above threshold)
File Function Severity Cyclomatic Cognitive CRAP Lines
singles/services/single-mutation-service.ts:981 <arrow> critical 251 ! 324 ! 13859.2 ! 1625
collections/services/collection-mutation-service.ts:6209 <arrow> critical 174 ! 177 ! 6713.6 ! 1301
src/init/reload-config.ts:1319 applyReload critical 144 ! 228 ! 4623 ! 1433
shared/lib/entry-validation.ts:223 validateFieldValue critical 109 ! 157 ! 2675.3 ! 432
blocks-engine/src/measure-bytes.ts:646 surveyDocument critical 102 ! 250 ! 137.1 ! 658

4990 files, 76187 functions analyzed (thresholds: cyclomatic > 20, cognitive > 15, CRAP >= 30)

Codebase health

Metric Value
Maintainability 91.7 / 100
Avg complexity 1.8

Tip

Run fallow fix --dry-run to preview auto-fixes.
Add /** @public */ above exports to preserve them.

@mobeenabdullah
mobeenabdullah merged commit ead1c91 into main Sep 10, 2026
15 of 19 checks passed
@github-actions github-actions Bot added the scope: core nextly label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant