{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/daniloaguiarbr/sqlite-graphrag/schemas/debug-schema.schema.json",
"title": "DebugSchemaResponse",
"description": "Response emitted by the hidden `sqlite-graphrag __debug_schema` subcommand on stdout as a single JSON line. Intended for diagnostic tooling only. The binary exposes this command as `__debug_schema` (double-underscore prefix) while this schema file uses the kebab-case convention `debug-schema.schema.json`. IMPORTANT: `user_version` is a compile-time constant (SCHEMA_USER_VERSION) that is ONE AHEAD of the applied migrations count; `schema_version` is `MAX(version)` from `refinery_schema_history` (the last applied migration). Both values are logically correct but serve distinct purposes: `user_version` signals the target schema the binary was built for; `schema_version` signals what is actually applied in the database. A healthy database has `user_version = schema_version + 1`.",
"$defs": {
"SchemaObject": {
"type": "object",
"required": ["name", "type"],
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"type": { "type": "string", "enum": ["table", "view", "trigger", "index"] }
}
},
"MigrationRecord": {
"type": "object",
"required": ["version", "name", "applied_on"],
"additionalProperties": false,
"properties": {
"version": { "type": "integer" },
"name": { "type": "string" },
"applied_on": { "type": "string", "description": "ISO 8601 timestamp string." }
}
}
},
"type": "object",
"required": ["schema_version", "user_version", "objects", "migrations", "elapsed_ms"],
"additionalProperties": false,
"properties": {
"schema_version": { "type": "integer", "description": "MAX(version) from refinery_schema_history — the last migration actually applied to this database file. Grows by 1 per migration." },
"user_version": { "type": "integer", "description": "SQLite PRAGMA user_version — compile-time constant SCHEMA_USER_VERSION baked into the binary. Equals schema_version + 1 in a healthy, fully-migrated database." },
"objects": { "type": "array", "items": { "$ref": "#/$defs/SchemaObject" } },
"migrations": { "type": "array", "items": { "$ref": "#/$defs/MigrationRecord" } },
"elapsed_ms": { "type": "integer", "minimum": 0 }
}
}