UNPKG

@clickup/pg-microsharding

Version:
29 lines 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runSqlProgressNonTransactional = runSqlProgressNonTransactional; exports.runSqlProgressTransactional = runSqlProgressTransactional; const names_1 = require("./names"); const runShell_1 = require("./runShell"); /** * SLOW: runs a psql with the provided SQL query (or queries) passed as stdin. * - Does NOT run in a single-transaction mode. * - Suitable for slow queries, like indexes and FKs creation. * - Prints progress as it goes (suitable for slow queries). * - Logs the progress unique lines to the log file if it's attached. */ async function runSqlProgressNonTransactional(dsn, query, comment) { await (0, runShell_1.runShell)(`${(0, names_1.psql)(dsn)} -a`, query.toString(), comment, "progress"); } /** * FAST: runs a psql with the provided SQL query (or queries) passed as stdin. * - Runs in a single-transaction mode. * - Suitable for fast queries, like pre-data dump restoration. * - Prints progress as it goes (suitable for slow queries). * - Does NOT log the progress unique lines to the log file (assuming that the * SQL queries are so bulky that it makes no sense to log them). */ async function runSqlProgressTransactional(dsn, query, comment) { await (0, runShell_1.runShell)(`${(0, names_1.psql)(dsn)} -a -1`, // -1 means "single-transaction" query.toString(), comment, "progress.unlogged"); } //# sourceMappingURL=runSqlProgress.js.map