Add integrityCheck() function#8958
Conversation
…ike/fix-pragma
…ike/fix-pragma
…ike/fix-pragma
…ike/fix-pragma
core/backend/src/IntegrityCheck.ts
Outdated
| import { IModelError } from "@itwin/core-common/lib/cjs/IModelError"; | ||
| import { IModelDb } from "./IModelDb"; | ||
|
|
||
| /** Integrity check types with their display names |
There was a problem hiding this comment.
Keep that internal on in test. The issue with pragma integrity check is it's not lazy loading rows. If you full result set then get ready to get like millions of rows as well. Which some db do have.
We need to improve this by instead providing virtual table or something that can step as you step through result.
There was a problem hiding this comment.
I have moved the integryCheck.ts file into internal completely.
Should I look at capping the results I return in TS to 1000?
There was a problem hiding this comment.
Pull request overview
Adds a new IModelDb.integrityCheck() API (beta) to run PRAGMA integrity_check (quick and specific sub-checks) from TypeScript, along with parsing helpers and tests.
Changes:
- Added internal integrity-check helpers/types to map check options to PRAGMA queries and normalize result rows.
- Introduced
IModelDb.integrityCheck(options?)and newIntegrityCheckOptionsAPI. - Added standalone tests covering quick/specific checks and a corruption scenario.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| core/backend/src/internal/IntegrityCheck.ts | Implements check mapping, friendly names, and execution/parsing helpers for quick + specific PRAGMA checks. |
| core/backend/src/IModelDb.ts | Exposes new integrityCheck() method and IntegrityCheckOptions interface on IModelDb. |
| core/backend/src/test/standalone/IntegrityCheck.test.ts | Adds unit/integration tests for helper functions and the new IModelDb.integrityCheck() behavior. |
| core/backend/src/test/standalone/ChangesetReader.test.ts | Adds PRAGMA integrity_check coverage but currently forces the suite to run exclusively. |
| common/changes/@itwin/core-backend/*.json | Adds (duplicated) change files for the new API, one with an empty comment. |
| common/api/* | Updates extracted API docs/exports for new beta interface + method. |
| .vscode/cSpell.json | Adds “Linktable” to spellchecker dictionary. |
common/changes/@itwin/core-backend/mike-fix-pragma_2026-02-02-17-58.json
Show resolved
Hide resolved
common/changes/@itwin/core-backend/mike-fix-pragma_2026-02-06-16-41.json
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… into mike/fix-pragma
imodel-native: iTwin/imodel-native#1324
Adds a new function to IModelDb that allows the user to call PRAGMA integrity_check, and all of its specific sub queries. This exposes the ability to triage iModel state from TS. Also parses its output as Typescript would expect.
Types of checks:
Default Check:
Specific Checks:
Data Schema Check: Checks if all the required data tables and indexes exist for mapped classes. Issues are returned as a list of tables/columns which were not found or have different DDL.
Implements: https://github.com/iTwin/itwinjs-backlog/issues/1811?issue=iTwin%7Citwinjs-backlog%7C1848