Skip to content

Commit

Permalink
explicitly handle version 15 and 16 and update latest version (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigorn0 authored Sep 11, 2024
1 parent f081aa9 commit 3354a5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion properties_pane/defaultData.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"model": {
"modelName": "New model",
"dbVersion": "v15.x",
"dbVersion": "v16.x",
"dbVendor": "PostgreSQL"
},
"container": {
Expand Down
15 changes: 11 additions & 4 deletions reverse_engineering/helpers/postgresService.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const { mapSequenceData } = require('./postgresHelpers/sequenceHelper');
let useSshTunnel = false;
let _ = null;
let logger = null;
let version = 14;
let version = 16;

module.exports = {
setDependencies(app) {
Expand Down Expand Up @@ -102,9 +102,9 @@ module.exports = {

async logVersion() {
const versionRow = await db.queryTolerant(queryConstants.GET_VERSION, [], true);
const version = versionRow?.version || 'Version not retrieved';
const serverVersion = versionRow?.version || 'Version not retrieved';

logger.info(`PostgreSQL version: ${version}`);
logger.info(`PostgreSQL version: ${serverVersion}`);
},

async getAllSchemasNames() {
Expand Down Expand Up @@ -135,12 +135,14 @@ module.exports = {
const database_name = (await db.queryTolerant(queryConstants.GET_DB_NAME, [], true))?.current_database;
const encoding = (await db.queryTolerant(queryConstants.GET_DB_ENCODING, [], true))?.server_encoding;
const LC_COLLATE = (await db.queryTolerant(queryConstants.GET_DB_COLLATE_NAME, [], true))?.default_collate_name;
const dbVersion = `v${await this._getServerVersion()}.x`;

return clearEmptyPropertiesInObject({
database_name,
encoding,
LC_COLLATE,
LC_CTYPE: LC_COLLATE,
dbVersion,
});
},

Expand Down Expand Up @@ -441,6 +443,7 @@ module.exports = {
async _getServerVersion() {
const result = await db.queryTolerant(queryConstants.GET_VERSION_AS_NUM, [], true);
const serverVersionNum = _.toNumber(result?.server_version_num);
const latestPgVersion = 16;

if (serverVersionNum >= 100000 && serverVersionNum < 110000) {
return 10;
Expand All @@ -452,9 +455,13 @@ module.exports = {
return 13;
} else if (serverVersionNum >= 140000 && serverVersionNum < 150000) {
return 14;
} else if (serverVersionNum >= 150000 && serverVersionNum < 160000) {
return 15;
} else if (serverVersionNum >= 160000 && serverVersionNum < 170000) {
return 16;
}

return 14;
return latestPgVersion;
},
};

Expand Down

0 comments on commit 3354a5b

Please sign in to comment.