import type {MigrationParams} from '../types' export type UmzugStorage = { /** * Logs migration to be considered as executed. */ logMigration: (params: MigrationParams) => Promise /** * Unlogs migration (makes it to be considered as pending). */ unlogMigration: (params: MigrationParams) => Promise /** * Gets list of executed migrations. */ executed: (meta: Pick, 'context'>) => Promise } export function isUmzugStorage(arg: Partial): arg is UmzugStorage { return ( arg && typeof arg.logMigration === 'function' && typeof arg.unlogMigration === 'function' && typeof arg.executed === 'function' ) } export const verifyUmzugStorage = (arg: Partial): UmzugStorage => { if (!isUmzugStorage(arg)) { throw new Error(`Invalid umzug storage`) } return arg }