feat: add useTransaction option to deployDb

This commit is contained in:
Pavel
2025-05-29 22:52:38 +02:00
parent 2766aedc01
commit 225520a765
6 changed files with 20 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ const logger = getLogger('execQuery');
* @param {string} [options.sql] - SQL query
* @param {string} [options.sqlFile] - SQL file
* @param {boolean} [options.logScriptItems] - whether to log script items instead of whole script
* @param {boolean} [options.useTransaction] - run query in transaction
*/
async function executeQuery({
connection = undefined,
@@ -22,6 +23,7 @@ async function executeQuery({
sql,
sqlFile = undefined,
logScriptItems = false,
useTransaction,
}) {
if (!logScriptItems) {
logger.info({ sql: getLimitedQuery(sql) }, `Execute query`);
@@ -38,7 +40,7 @@ async function executeQuery({
try {
logger.debug(`Running SQL query, length: ${sql.length}`);
await driver.script(dbhan, sql, { logScriptItems });
await driver.script(dbhan, sql, { logScriptItems, useTransaction });
} finally {
if (!systemConnection) {
await driver.close(dbhan);