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

Method run

packages/config/src/migrations/runner.ts:49–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47 }
48
49 async run(): Promise<{ executed: number; currentVersion: number }> {
50 const currentVersion = this.getCurrentVersion()
51 const pending = this.migrations.filter((m) => m.version > currentVersion)
52
53 if (pending.length === 0) {
54 return { executed: 0, currentVersion }
55 }
56
57 this.context.logger.info('Migration', `${pending.length} pending migration(s), current version: ${currentVersion}`)
58
59 let lastVersion = currentVersion
60 let executed = 0
61
62 for (const migration of pending) {
63 this.context.logger.info('Migration', `Running: v${lastVersion}→v${migration.version} ${migration.name}`)
64 try {
65 await migration.up(this.context)
66 lastVersion = migration.version
67 this.writeVersion(lastVersion)
68 executed++
69 this.context.logger.info('Migration', `Completed: ${migration.name}`)
70 } catch (err) {
71 this.context.logger.error('Migration', `Failed: ${migration.name}`, err)
72 break
73 }
74 }
75
76 return { executed, currentVersion: lastVersion }
77 }
78}

Callers 1

startHttpServerFunction · 0.95

Calls 5

getCurrentVersionMethod · 0.95
writeVersionMethod · 0.95
upMethod · 0.80
infoMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected