Skip to content

Commit

Permalink
feat: added log about db version
Browse files Browse the repository at this point in the history
  • Loading branch information
chulanovskyi-bs committed Oct 21, 2024
1 parent 5edc85e commit f325eb9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
12 changes: 10 additions & 2 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ module.exports = {
() => {
logger.log('info', 'Successfully connected to the database instance', 'Connection');

neo4j.getRawDbVersion().then(dbVersion => {
logger.log('info', `Database version ${dbVersion}`);
});

cb();
},
error => {
Expand Down Expand Up @@ -70,7 +74,9 @@ module.exports = {
neo4j.setTimeOut(connectionInfo);

await neo4j.connect(connectionInfo, checkConnection(logger), sshService);
logger.log('info', 'Successfully connected to the database instance', 'Connection');

const dbVersion = await neo4j.getRawDbVersion();
logger.log('info', `Successfully connected to the database instance: ${dbVersion}`, 'Connection');

const isMultiDb = await neo4j.supportsMultiDb();
logger.log('info', `Multi database support: ${isMultiDb}`, step);
Expand Down Expand Up @@ -139,8 +145,10 @@ module.exports = {
logger.log('info', '', 'Start Reverse Engineering Neo4j');

const isMultiDb = await neo4j.supportsMultiDb();
const dbVersion = await neo4j.getDbVersion();
logger.log('info', `Database version: ${dbVersion}`);
const modelProps = {
dbVersion: await neo4j.getDbVersion(),
dbVersion,
};

async.map(
Expand Down
26 changes: 17 additions & 9 deletions reverse_engineering/neo4jHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,27 @@ const getSSLConfig = info => {
}
};

const getRawDbVersion = async () => {
const versionResponse = await execute(
'call dbms.components() yield versions unwind versions as version return version',
);
return _.head(versionResponse)?.version;
};

const getDbVersion = async () => {
try {
const versionResponse = await execute(
'call dbms.components() yield versions unwind versions as version return version',
);
const version = _.get(versionResponse, '[0].version');
const splittedVersion = version.split('.');
if (splittedVersion[0] === '4' && splittedVersion[1] === '3') {
const version = await getRawDbVersion();
const [major, minor] = version.split('.');
const v4 = major === '4';
const v5 = major === '5';

if (v4 && minor === '3') {
return '4.3';
} else if (splittedVersion[0] === '4' && splittedVersion[1] >= '4') {
} else if (v4 && minor >= '4') {
return '4.4';
} else if (version.startsWith('4')) {
} else if (v4) {
return '4.0-4.2';
} else if (version.startsWith('5')) {
} else if (v5) {
return '5.x';
}
return '3.x';
Expand Down Expand Up @@ -439,4 +446,5 @@ module.exports = {
isTemporalTypeField,
getTemporalFieldSchema,
execute,
getRawDbVersion,
};

0 comments on commit f325eb9

Please sign in to comment.