mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-17 18:14:05 -08:00
027dfb2f0a
* ⚡ Enable `esModuleInterop` for /core * ⚡ Adjust imports in /core * ⚡ Enable `esModuleInterop` for /cli * ⚡ Adjust imports in /cli * ⚡ Enable `esModuleInterop` for /nodes-base * ⚡ Adjust imports in /nodes-base * ⚡ Make imports consistent * ⬆️ Upgrade TypeScript to 4.6 (#3109) * ⬆️ Upgrade TypeScript to 4.6 * 📦 Update package-lock.json * 🔧 Avoid erroring on untyped errors * 📘 Fix type error Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { exec as callbackExec } from 'child_process';
|
|
import { promisify } from 'util';
|
|
|
|
import config from '../config';
|
|
import { BOOTSTRAP_MYSQL_CONNECTION_NAME } from './integration/shared/constants';
|
|
|
|
const exec = promisify(callbackExec);
|
|
|
|
const dbType = config.getEnv('database.type');
|
|
|
|
if (dbType === 'mysqldb') {
|
|
const username = config.getEnv('database.mysqldb.user');
|
|
const password = config.getEnv('database.mysqldb.password');
|
|
const host = config.getEnv('database.mysqldb.host');
|
|
|
|
const passwordSegment = password ? `-p${password}` : '';
|
|
|
|
(async () => {
|
|
try {
|
|
jest.setTimeout(30000); // 30 seconds for DB initialization
|
|
await exec(
|
|
`echo "CREATE DATABASE IF NOT EXISTS ${BOOTSTRAP_MYSQL_CONNECTION_NAME}" | mysql -h ${host} -u ${username} ${passwordSegment}; USE ${BOOTSTRAP_MYSQL_CONNECTION_NAME};`,
|
|
);
|
|
} catch (error) {
|
|
if (error.stderr.includes('Access denied')) {
|
|
console.error(
|
|
`ERROR: Failed to log into MySQL to create bootstrap DB.\nPlease review your MySQL connection options:\n\thost: "${host}"\n\tusername: "${username}"\n\tpassword: "${password}"\nFix by setting correct values via environment variables.\n\texport DB_MYSQLDB_HOST=value\n\texport DB_MYSQLDB_USERNAME=value\n\texport DB_MYSQLDB_PASSWORD=value`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
})();
|
|
}
|