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

Function checkDatabaseIntegrity

apps/desktop/main/database/migrations.ts:51–66  ·  view source on GitHub ↗
(db: DatabaseAdapter)

Source from the content-addressed store, hash-verified

49)
50
51function checkDatabaseIntegrity(db: DatabaseAdapter): { valid: boolean; error?: string } {
52 try {
53 const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='meta'").all() as Array<{
54 name: string
55 }>
56 if (tables.length === 0) {
57 return { valid: false, error: t('database.integrityError') }
58 }
59 return { valid: true }
60 } catch (error) {
61 return {
62 valid: false,
63 error: t('database.checkFailed', { error: error instanceof Error ? error.message : String(error) }),
64 }
65 }
66}
67
68/**
69 * Execute database migrations.

Callers 1

migrateDatabaseFunction · 0.85

Calls 3

tFunction · 0.90
allMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected