rake-db 2.33.1 → 2.33.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -86,7 +86,7 @@ const makePopulateEnumQuery = (schema, item) => {
|
|
|
86
86
|
};
|
|
87
87
|
const transaction = (adapter, config, fn) => {
|
|
88
88
|
const searchPath = config.transactionSearchPath;
|
|
89
|
-
return adapter.transaction(searchPath ? {
|
|
89
|
+
return adapter.transaction(void 0, searchPath ? { setConfig: { search_path: typeof searchPath === "function" ? searchPath() : searchPath } } : void 0, fn);
|
|
90
90
|
};
|
|
91
91
|
const queryLock = (trx) => trx.query(`SELECT pg_advisory_xact_lock('${RAKE_DB_LOCK_KEY}')`);
|
|
92
92
|
const getCliParam = (args, name) => {
|
|
@@ -1062,7 +1062,9 @@ const astToQuery = (ast) => {
|
|
|
1062
1062
|
w.push(serializers[key](value));
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
|
-
|
|
1065
|
+
const escapedRoleName = ast.name.replace(/'/g, "''");
|
|
1066
|
+
const roleSql = `${ast.action.toUpperCase()} ROLE "${ast.name}"${w.length ? ` WITH ${w.join(" ")}` : ""}`;
|
|
1067
|
+
let sql = ast.action === "create" ? `DO $$\nBEGIN\n IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '${escapedRoleName}') THEN\n ${roleSql};\n END IF;\nEND\n$$` : roleSql;
|
|
1066
1068
|
if (ast.action !== "drop" && ast.config) for (const [key, value] of Object.entries(ast.config)) sql += `;\nALTER ROLE "${ast.name}" SET ${key} = '${value}'`;
|
|
1067
1069
|
return sql;
|
|
1068
1070
|
};
|
|
@@ -3219,7 +3221,7 @@ const createOrDropDatabase = async (action, adapters, config, dontClose) => {
|
|
|
3219
3221
|
askAdminCreds: () => askForAdminCredentials(action === "create")
|
|
3220
3222
|
})) continue;
|
|
3221
3223
|
if (action === "create") {
|
|
3222
|
-
await adapter.transaction(async (tx) => {
|
|
3224
|
+
await adapter.transaction(void 0, void 0, async (tx) => {
|
|
3223
3225
|
const schema = adapter.getSchema();
|
|
3224
3226
|
if (schema) {
|
|
3225
3227
|
const quoted = `"${typeof schema === "function" ? schema() : schema}"`;
|