UNPKG

@clickup/pg-mig

Version:

PostgreSQL schema migration tool with microsharding and clustering support

47 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.wrapNonTransactional = wrapNonTransactional; const fs_1 = require("fs"); const path_1 = require("path"); const validateCreateIndexConcurrently_1 = require("./validateCreateIndexConcurrently"); const validateDropIndexConcurrently_1 = require("./validateDropIndexConcurrently"); function wrapNonTransactional(fileName, vars) { const content = (0, fs_1.readFileSync)(fileName).toString(); const include = `\\i ${(0, path_1.basename)(fileName)}`; const resCreate = (0, validateCreateIndexConcurrently_1.validateCreateIndexConcurrently)(content, vars); if (resCreate.type === "success-index-alone") { return { lines: [ "COMMIT;", `DROP INDEX CONCURRENTLY IF EXISTS ${resCreate.indexNamesQuoted[0]};`, include, "BEGIN;", ], errors: [], }; } else if (resCreate.type === "error") { return { lines: [], errors: resCreate.errors, }; } const resDrop = (0, validateDropIndexConcurrently_1.validateDropIndexConcurrently)(content); if (resDrop.type === "success-index-alone") { return { lines: ["COMMIT;", include, "BEGIN;"], errors: [], }; } else if (resDrop.type === "error") { return { lines: [], errors: resDrop.errors, }; } return { lines: [include], errors: [], }; } //# sourceMappingURL=wrapNonTransactional.js.map