Class: SchemaCompat
Defined in: Data/Core/SchemaCompat.ts:41
Per-connection schema probe with cached results.
Instances are keyed off the ISql object identity, so repeated repository construction against the same connection costs one probe per table.
Methods
bibleFormattingColumn()
bibleFormattingColumn():
"formatting"|"formatting_data"|undefined
Defined in: Data/Core/SchemaCompat.ts:147
WS-2: the column holding verse formatting JSON.
v2 = formatting, v1 = formatting_data.
Returns
"formatting" | "formatting_data" | undefined
bibleFtsColumns()
bibleFtsColumns():
object
Defined in: Data/Core/SchemaCompat.ts:177
WS-2: the bible_verse_fts column indices to pass to highlight().
Deliberately asks the FTS table rather than inferring from
hasBibleTextPlain, which describes bible_verse. The two schemas
are declared separately and can disagree per module — and highlight()
does not raise on a column that is not there, it returns an empty string.
That failure is silent and total: the search result keeps its verse id, so
the reference renders and the verse text comes back blank.
The canonical shape is (verse_id UNINDEXED, text), but a module built
without the leading verse_id column puts text at 0, and a v1 module
adds text_plain at 2. Read the positions rather than assuming any of them.
Returns
object
plain
plain:
number
text
text:
number
columns()
columns(
table):ReadonlySet<string>
Defined in: Data/Core/SchemaCompat.ts:100
The set of column names on a table (lower-cased). Empty if absent.
Parameters
table
string
Returns
ReadonlySet<string>
crossRefGroupAnchor()
crossRefGroupAnchor(): {
end:string;start:string; } |undefined
Defined in: Data/Core/SchemaCompat.ts:274
WS-3: the source-anchor columns of cross_reference_group.
v2 normalises the anchor to the canonical inclusive range
verse_id_start / verse_id_end (§5). A v1 module carries a single bare
verse_id, in which case both names resolve to it — so every containment
and overlap predicate can be written once, in the v2 form, and still be
correct on v1 (verse_id <= v AND verse_id >= v is verse_id = v).
Returns the two literal column names, never caller input, so the result is
safe to interpolate into a query. undefined if the table is absent.
Returns
{ end: string; start: string; } | undefined
hasBibleTextPlain()
hasBibleTextPlain():
boolean
Defined in: Data/Core/SchemaCompat.ts:159
WS-2: whether bible_verse.text_plain still exists.
In v1, text holds presentational HTML and text_plain holds the (roughly)
stripped variant, so callers asking for plain text must read text_plain.
In v2 text is already clean and text_plain is gone.
Returns
boolean
hasColumn()
hasColumn(
table,column):boolean
Defined in: Data/Core/SchemaCompat.ts:123
True if table exists and has a column named column.
Parameters
table
string
column
string
Returns
boolean
hasDictionaryExampleVersesColumn()
hasDictionaryExampleVersesColumn():
boolean
Defined in: Data/Core/SchemaCompat.ts:240
WS-3: whether the dictionary still carries the JSON example_verses column.
Removed in v2 — example verses are verse_link rows there.
Returns
boolean
hasModuleIdentity()
hasModuleIdentity():
boolean
Defined in: Data/Core/SchemaCompat.ts:215
WS-4: whether module_info carries the v2 identity block.
Returns
boolean
hasTable()
hasTable(
table):boolean
Defined in: Data/Core/SchemaCompat.ts:84
True if a table or view with this name exists.
Parameters
table
string
Returns
boolean
hasUnifiedVerseLink()
hasUnifiedVerseLink():
boolean
Defined in: Data/Core/SchemaCompat.ts:206
WS-3: whether verse_link is the unified v2 shape.
The user database already shipped a verse_link row type keyed by
note_id; the v2 table is keyed by (source_type, source_id). Only the
latter is usable as the unified link table.
Returns
boolean
hasVerseLink()
hasVerseLink():
boolean
Defined in: Data/Core/SchemaCompat.ts:195
WS-3: whether the unified verse_link table is present.
Returns
boolean
invalidate()
invalidate():
void
Defined in: Data/Core/SchemaCompat.ts:74
Drop this instance's cached probe results.
Returns
void
isBibleFormattingV2()
isBibleFormattingV2():
boolean
Defined in: Data/Core/SchemaCompat.ts:190
True when the database carries the v2 bible_verse.formatting column.
Returns
boolean
pickColumn()
pickColumn(
table, ...candidates):string|undefined
Defined in: Data/Core/SchemaCompat.ts:131
Return the first of candidates that exists as a column on table.
Used to prefer a v2 column name and fall back to its v1 spelling.
Parameters
table
string
candidates
...string[]
Returns
string | undefined
topicFtsTable()
topicFtsTable():
string|undefined
Defined in: Data/Core/SchemaCompat.ts:291
The topic FTS5 table name — v2 topic_fts, v1 converter output topics_fts.
Returns
string | undefined
topicTable()
topicTable():
string|undefined
Defined in: Data/Core/SchemaCompat.ts:286
The topic table name — v2 singular topic, v1 converter output topics.
The return value is always one of the two literals below, never caller input, so it is safe to interpolate into a query.
Returns
string | undefined
topicVerseShape()
topicVerseShape(): {
end:string;start:string;table:string; } |undefined
Defined in: Data/Core/SchemaCompat.ts:252
WS-3: the topical index's topic↔verse table and its range columns.
The shipped converter emitted plural table names (topics, topic_verses)
with reversed column spellings (start_verse_id / end_verse_id). v2
uses singular topic plus the unified verse_link, and the canonical
spelling verse_id_start / verse_id_end.
Returns
{ end: string; start: string; table: string; } | undefined
wordOccurrenceModuleColumn()
wordOccurrenceModuleColumn():
"bible_module_uuid"|"module_uuid"|"bible_module"|undefined
Defined in: Data/Core/SchemaCompat.ts:226
WS-4: the column identifying the Bible a word occurrence was counted in.
v2 = bible_module_uuid (joins module_info.module_uuid).
v1 COMPAT = bible_module, a bare abbreviation used as a soft cross-database
reference. module_uuid is accepted as a tolerated spelling.
Returns
"bible_module_uuid" | "module_uuid" | "bible_module" | undefined
for()
staticfor(sql):SchemaCompat
Defined in: Data/Core/SchemaCompat.ts:57
Get (or create) the cached probe for a connection.
Parameters
sql
The connection to probe
Returns
SchemaCompat
invalidate()
staticinvalidate(sql):void
Defined in: Data/Core/SchemaCompat.ts:69
Drop all cached probe results for a connection. Call after DDL that adds or removes tables/columns on a live connection.
Parameters
sql
Returns
void