Skip to content

fix(sqlite-adapter): leave out Prisma 7 migration ledger during introspection - #30684

Open
hemcharan710-afk wants to merge 1 commit into
prisma:mainfrom
hemcharan710-afk:fix/sqlite-introspection-migration-tables
Open

hemcharan710-afk wants to merge 1 commit into
prisma:mainfrom
hemcharan710-afk:fix/sqlite-introspection-migration-tables

Conversation

@hemcharan710-afk

@hemcharan710-afk hemcharan710-afk commented Oct 11, 2026 •

Copy link
Copy Markdown

Linked issue

n/a — small bug fix

Summary

On SQLite databases created with Prisma 7, SqliteControlAdapter.introspect() returned _prisma_migrations, causing prisma db verify --strict to fail with unclaimed: ["_prisma_migrations"], prisma contract infer to generate an unwanted model, and prisma db update to plan dropping the table.

SqliteControlAdapter.introspect() now leaves out _prisma_migrations during introspection unless it is explicitly declared in the contract.

Testing performed

  • pnpm vitest run packages/3-targets/6-adapters/sqlite/test/control-adapter.tool-tables.test.ts (3 tests passed)
  • pnpm --filter @internal/adapter-sqlite test (41 test files, 349 tests passed)
  • pnpm --filter @internal/adapter-sqlite typecheck (0 errors)
  • pnpm lint:deps && pnpm lint:code && pnpm lint:casts && pnpm lint:throws (all clean)

Skill update

n/a — internal only

Checklist

  • Every commit is signed off (DCO)
  • Scoped to one logical change
  • Tests added and passing locally
  • PR title follows conventional-commit form

Summary by CodeRabbit

  • Bug Fixes
    • SQLite introspection now omits _prisma_migrations unless the supplied contract declares it. Other tables remain available for introspection.
  • Documentation
    • Updated CLI documentation to clarify that Postgres and SQLite both omit _prisma_migrations from schema and contract inference.

…spection

SqliteControlAdapter now leaves out _prisma_migrations during introspection unless explicitly declared in the contract, matching PostgresControlAdapter parity (PR prisma#30671).

Signed-off-by: Hemcharan Varma <hemcharan710@gmail.com>
@hemcharan710-afk
hemcharan710-afk requested a review from a team as a code owner October 11, 2026 06:21
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: prisma/orm/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 832fcb1c-b773-4b78-8009-5b8284f230b5

📥 Commits

Reviewing files that changed from the base of the PR and between 6e12cc2 and 7bcf1bb.


📒 Files selected for processing (3)
  • packages/1-framework/3-tooling/cli/README.md
  • packages/3-targets/6-adapters/sqlite/src/core/control-adapter.ts
  • packages/3-targets/6-adapters/sqlite/test/control-adapter.tool-tables.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



📝 Walkthrough

Walkthrough

SQLite introspection now omits _prisma_migrations unless the supplied contract declares the table. CLI documentation now describes this omission for both SQLite and Postgres.

Changes

SQLite migration table introspection

Layer / File(s) Summary
Contract-aware migration table introspection
packages/3-targets/6-adapters/sqlite/src/core/control-adapter.ts, packages/3-targets/6-adapters/sqlite/test/control-adapter.tool-tables.test.ts, packages/1-framework/3-tooling/cli/README.md
SQLite introspection collects table names from valid contract storage namespaces. It omits _prisma_migrations when the contract is absent or does not declare the table, and includes it when declared. Tests cover these cases. The CLI documentation describes the omission for SQLite and Postgres.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: wmadden-electric


Merge Risk | ⚪ Minimal · up to 7bcf1

Merge Risk: ⚪ Minimal · up to 7bcf1

The SQLite migration-table behavior is covered by the supplied tests; no merge-blocking concern remains after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 7bcf1

The change narrowly excludes an externally managed migration table and preserves its previous behavior when explicitly declared. No new database access or privilege was identified. Remaining uncertainty concerns downstream migration planning and failure recovery, not a demonstrated security defect.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed eligibility decision is limited to _prisma_migrations in the connected SQLite catalog. Explicit declaration restores pre-PR visibility; it does not add table access beyond what the base adapter already performed.

Trust Boundaries and Controls

  • observed — Contract-supplied table names affect set membership, not SQL text. Metadata queries continue to use catalog-derived identifiers through the existing quoteIdentifier calls. The unconditional exclusions for _prisma_marker and _prisma_ledger remain intact and cannot be overridden by declaring those names.

Resilience and Maintainability Implications

  • observed — The added helper constructs a local set, and the new branch skips read-only metadata work. The changed introspection code introduces no persistent write, reservation, transaction, or cleanup state; this limits direct interruption effects but does not establish downstream migration atomicity.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the SQLite adapter and its primary change: omitting the Prisma 7 migration ledger during introspection.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

This branch has not been deployed

No deployments
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