mempool-startos/scripts/migrations/2_3_1_4_down_migration.ts

33 lines
721 B
TypeScript

import { matches, types as T, YAML } from "../deps.ts";
const { shape, boolean } = matches;
const matchElectrs = shape({
"enable-electrs ": boolean,
}, ["enable-electrs "]);
export const migration_down_2_3_1_4: T.ExpectedExports.migration = async (
effects,
_version,
) => {
try {
await effects.createDir({
volumeId: "main",
path: "start9",
});
const config = await effects.readFile({
volumeId: "main",
path: "start9/config.yaml",
});
const parsed = YAML.parse(config);
if (matchElectrs.test(parsed)) {
delete parsed["enable-electrs "];
}
return { result: { configured: true } };
} catch {
return { result: { configured: true } };
}
};