UNPKG

@clickup/pg-microsharding

Version:
24 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.install = install; const fs_1 = require("fs"); const path_1 = require("path"); const names_1 = require("../internal/names"); const quote_1 = require("../internal/quote"); const runSqlProgress_1 = require("../internal/runSqlProgress"); /** * Installs/updates microsharding schema and functions. */ async function install({ dsn, schemaNameFmt, }) { const scriptPath = (0, path_1.relative)(".", (0, fs_1.realpathSync)(`${__dirname}/../../sql/pg-microsharding-up.sql`)); await (0, runSqlProgress_1.runSqlProgressTransactional)(dsn, (0, quote_1.join)([ (0, quote_1.sql) ` CREATE SCHEMA IF NOT EXISTS ${(0, names_1.libSchema)()}; SET search_path TO ${(0, names_1.libSchema)()}; \\setenv PG_MICROSHARDING_SCHEMA_NAME_FMT ${schemaNameFmt !== null && schemaNameFmt !== void 0 ? schemaNameFmt : ""} `, `\\i ${scriptPath}`, ], "\n"), `Updating the library at ${dsn}` + (schemaNameFmt ? ` with schema name fmt "${schemaNameFmt}"` : "")); } //# sourceMappingURL=install.js.map