| 35 | } |
| 36 | |
| 37 | private writeVersion(version: number): void { |
| 38 | const versionPath = path.join(this.context.dataDir, VERSION_FILE) |
| 39 | try { |
| 40 | if (!fs.existsSync(this.context.dataDir)) { |
| 41 | fs.mkdirSync(this.context.dataDir, { recursive: true }) |
| 42 | } |
| 43 | fs.writeFileSync(versionPath, String(version), 'utf-8') |
| 44 | } catch (err) { |
| 45 | this.context.logger.error('Migration', `Failed to write version file: ${err}`) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | async run(): Promise<{ executed: number; currentVersion: number }> { |
| 50 | const currentVersion = this.getCurrentVersion() |