import { BaseMigration } from './base-migration.ts'; import { logger } from '../logger.ts'; /** * Migration from v3 (upsList) to v4 (upsDevices) * * Detects v3 format: * { * upsList: [ ... ], * groups: [ ... ], * checkInterval: 30000 * } * * Converts to: * { * version: "4.0", * upsDevices: [ ... ], // renamed from upsList * groups: [ ... ], * checkInterval: 30000 * } */ export class MigrationV3ToV4 extends BaseMigration { readonly order = 4; readonly fromVersion = '3.x'; readonly toVersion = '4.0'; async shouldRun(config: any): Promise { // V3 format has upsList instead of upsDevices return !!config.upsList && !config.upsDevices; } async migrate(config: any): Promise { logger.info(`${this.getName()}: Renaming upsList to upsDevices...`); const migrated = { version: this.toVersion, upsDevices: config.upsList, // Rename upsList → upsDevices groups: config.groups || [], checkInterval: config.checkInterval || 30000, }; logger.success(`${this.getName()}: Migration complete`); return migrated; } }