import type * as plugins from '../ts/plugins.js'; import { runMigrationStep, type ISkrMigrationStep, type TSkrMigrationStepOutcome } from './helpers.migration.js'; import { ledgerUnificationStep } from './ledger.1.unifiedjournal.js'; import { storageTopologyStep } from './storage.2.topology.js'; /** Every step, in the order it runs. A step id is never reused or renumbered. */ export const skrMigrationSteps: readonly ISkrMigrationStep[] = [ ledgerUnificationStep, storageTopologyStep, ]; /** * Brings a database to what this skr version expects. Every step runs once * per database, records its report, and resumes after an interrupted run. * There is no way back: take a backup of the database first. */ export const runSkrMigrations = async ( db: plugins.nosqldb.SmartdataDb, ): Promise> => { const outcomes: Array<{ id: string; outcome: TSkrMigrationStepOutcome }> = []; for (const step of skrMigrationSteps) { outcomes.push({ id: step.id, outcome: await runMigrationStep(db, step) }); } return outcomes; }; export { SkrMigrationRecord, listAppliedMigrations } from './classes.migrationrecord.js'; export { findOposMetaDuplicates } from './storage.2.topology.js'; export type { ISkrMigrationRecord, TSkrMigrationReport, ILedgerUnificationReport, IStorageTopologyReport, } from './classes.migrationrecord.js'; export type { ISkrMigrationStep, ISkrMigrationRunContext, ISkrMigrationLeaseTiming, TSkrMigrationStepOutcome, } from './helpers.migration.js';