@clickup/pg-microsharding
Version:
Microshards support for PostgreSQL
39 lines • 1.73 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.actionCleanup = actionCleanup;
const chalk_1 = __importDefault(require("chalk"));
const prompts_1 = __importDefault(require("prompts"));
const cleanup_1 = require("../api/cleanup");
const logging_1 = require("../internal/logging");
const names_1 = require("../internal/names");
const normalizeDsns_1 = require("../internal/normalizeDsns");
/**
* Removes previously moved schema originals from the source database.
*/
async function actionCleanup(args) {
const dsns = await (0, normalizeDsns_1.normalizeDsns)(args["dsns"] || args["dsn"]);
if (dsns.length === 0) {
throw "Please provide --dsn or --dsns, DB DSNs to remove old schemas from";
}
for (const dsn of dsns) {
(0, logging_1.print)(`Cleaning up ${(0, names_1.dsnShort)(dsn)}`);
await (0, cleanup_1.cleanup)({
dsn,
noOldShards: async (oldSchemaNameRe) => (0, logging_1.print)(chalk_1.default.gray(`- No old microshard schemas matching regexp ${oldSchemaNameRe}`)),
confirm: async (schemas) => {
const response = await (0, prompts_1.default)({
type: "text",
name: "value",
message: `Delete redundant schemas ${schemas.join(", ")} (y/n)?`,
validate: (value) => value !== "y" && value !== "n" ? 'Enter "y" or "n".' : true,
});
return response.value === "y";
},
});
}
return true;
}
//# sourceMappingURL=actionCleanup.js.map