mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Reduce code duplication in DB config (no-changelog) (#8679)
This commit is contained in:
committed by
GitHub
parent
0e36aeb421
commit
b6c8a0c413
@@ -4,14 +4,14 @@ import config from '@/config';
|
||||
import { getBootstrapDBOptions, testDbPrefix } from './integration/shared/testDb';
|
||||
|
||||
export default async () => {
|
||||
const dbType = config.getEnv('database.type').replace(/db$/, '');
|
||||
if (dbType !== 'postgres' && dbType !== 'mysql') return;
|
||||
const dbType = config.getEnv('database.type');
|
||||
if (dbType !== 'postgresdb' && dbType !== 'mysqldb') return;
|
||||
|
||||
const connection = new Connection(getBootstrapDBOptions(dbType));
|
||||
await connection.initialize();
|
||||
|
||||
const query =
|
||||
dbType === 'postgres' ? 'SELECT datname as "Database" FROM pg_database' : 'SHOW DATABASES';
|
||||
dbType === 'postgresdb' ? 'SELECT datname as "Database" FROM pg_database' : 'SHOW DATABASES';
|
||||
const results: Array<{ Database: string }> = await connection.query(query);
|
||||
const databases = results
|
||||
.filter(({ Database: dbName }) => dbName.startsWith(testDbPrefix))
|
||||
|
||||
Reference in New Issue
Block a user