TenantAtlas/apps/platform/.pnpm-store/v10/files/2b/103a4bd3e73975dd6ad762d9e90e308345b085b9ea11470524c71124ed99871af4aaed89ab3aba3f46061cf2d67e3bb237663b1d565a8d70402af59e3e5fa4
Ahmed Darrazi 9f74f7a658
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 51s
feat: compress governance operator outcomes
2026-04-19 14:15:11 +02:00

34 lines
1.2 KiB
Plaintext

import crypto from "node:crypto";
import fs from "node:fs";
function readMigrationFiles(config) {
const migrationFolderTo = config.migrationsFolder;
const migrationQueries = [];
const journalPath = `${migrationFolderTo}/meta/_journal.json`;
if (!fs.existsSync(journalPath)) {
throw new Error(`Can't find meta/_journal.json file`);
}
const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
const journal = JSON.parse(journalAsString);
for (const journalEntry of journal.entries) {
const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
try {
const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
const result = query.split("--> statement-breakpoint").map((it) => {
return it;
});
migrationQueries.push({
sql: result,
bps: journalEntry.breakpoints,
folderMillis: journalEntry.when,
hash: crypto.createHash("sha256").update(query).digest("hex")
});
} catch {
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
}
}
return migrationQueries;
}
export {
readMigrationFiles
};
//# sourceMappingURL=migrator.js.map