import * as plugins from '../dist_ts/plugins.js'; import { type TSkrMigrationReport } from './classes.migrationrecord.js'; /** What a running step is handed besides the database. */ export interface ISkrMigrationRunContext { /** * Aborted once the step's lease passed to another process or can no longer * be renewed before it runs out; its reason is a `MigrationLeaseLostError`. * A step calls `signal.throwIfAborted()` before every write or transaction. */ signal: AbortSignal; } /** * One versioned migration step. `run` must be safe to resume after a crash at * any point: every write is idempotent or commits together with the marker * that makes a rerun skip it. */ export interface ISkrMigrationStep { id: string; description: string; run(db: plugins.nosqldb.SmartdataDb, context: ISkrMigrationRunContext): Promise; } export type TSkrMigrationStepOutcome = 'applied' | 'already_applied'; /** How long a lease lasts, and how often its holder renews it. */ export interface ISkrMigrationLeaseTiming { leaseMs: number; renewMs: number; } /** * Runs one step at most once per database, under a lease stored in its * record, so concurrent startups converge: one migrates, the others wait and * find it applied. The holder renews the lease while the step runs; once the * lease passes to another process, or cannot be renewed before it runs out, * the step's signal aborts and the step stops before its next write. The * report is persisted with the record by an owner-fenced write. */ export declare const runMigrationStep: (db: plugins.nosqldb.SmartdataDb, step: ISkrMigrationStep, timing?: ISkrMigrationLeaseTiming) => Promise;