MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / getSchemaVersion

Function getSchemaVersion

packages/core/src/schema/migrations.ts:20–33  ·  view source on GitHub ↗
(db: DatabaseAdapter)

Source from the content-addressed store, hash-verified

18 * 读取数据库的 schema 版本
19 */
20export function getSchemaVersion(db: DatabaseAdapter): number {
21 try {
22 const tableInfo = db.pragma('table_info(meta)') as Array<{ name: string }>
23 const hasVersionColumn = tableInfo.some((col) => col.name === 'schema_version')
24 if (!hasVersionColumn) return 0
25
26 const result = db.prepare('SELECT schema_version FROM meta LIMIT 1').get() as
27 | { schema_version: number | null }
28 | undefined
29 return result?.schema_version ?? 0
30 } catch {
31 return 0
32 }
33}
34
35/**
36 * 设置数据库的 schema 版本

Callers 6

migrateIfNeededMethod · 0.90
openWritableMethod · 0.90
runMigrationsMethod · 0.90
migrateDatabaseFunction · 0.90
needsMigrationFunction · 0.85
runMigrationsFunction · 0.85

Calls 3

pragmaMethod · 0.65
getMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected