fixed importing mysql dump #702

This commit is contained in:
SPRINX0\prochazka
2024-09-24 15:54:54 +02:00
parent 85bfb1986d
commit 517002e079
5 changed files with 16 additions and 4 deletions

View File

@@ -16,7 +16,7 @@ class ImportStream extends stream.Transform {
}
async _transform(chunk, encoding, cb) {
try {
await this.driver.script(this.pool, chunk);
await this.driver.script(this.pool, chunk, { queryOptions: { importSqlDump: true } });
} catch (err) {
this.emit('error', err.message);
}
@@ -47,7 +47,9 @@ async function importDatabase({ connection = undefined, systemConnection = undef
const pool = systemConnection || (await connectUtility(driver, connection, 'write'));
logger.info(`Connected.`);
logger.info(`Input file: ${inputFile}`);
const downloadedFile = await download(inputFile);
logger.info(`Downloaded file: ${downloadedFile}`);
const fileStream = fs.createReadStream(downloadedFile, 'utf-8');
const splittedStream = splitQueryStream(fileStream, driver.getQuerySplitterOptions('script'));

View File

@@ -11,7 +11,7 @@ async function runScript(func) {
await func();
process.exit(0);
} catch (err) {
logger.error({ err }, `Error running script: ${err.message}`);
logger.error({ err }, `Error running script: ${err.message || err}`);
process.exit(1);
}
}