From 158cde3cbcc2d795acc778e4b001d6a85ee5c26d Mon Sep 17 00:00:00 2001 From: Leonardo Beck Date: Sat, 8 Jan 2022 15:17:46 -0300 Subject: [PATCH] Updated makedb for latest Postgres Node module --- makedb/dbs/pg.js | 19 +++++++++---------- package.json | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/makedb/dbs/pg.js b/makedb/dbs/pg.js index 01d7c9af0..aab744c5d 100644 --- a/makedb/dbs/pg.js +++ b/makedb/dbs/pg.js @@ -4,7 +4,7 @@ 'use strict' -var pg = require("../../node_modules/sails-postgresql/node_modules/pg"); +const { Client } = require('pg') var dbConf = require("../../config/connections"); var _ = require("lodash"); var url = require('url'); @@ -82,14 +82,14 @@ module.exports = { } // console.log("Connection Options =>", opts); + const client = new Client(opts); - pg.connect(opts, function (err, client, done) { + client.connect(function (err) { if (err) { if(err.code == "3D000") { - console.log("Database `" + opts.database + "` does not exist. Creating..."); - done(); + console.log("Database `" + opts.database + "` does not exist. Creating..."); return self.create(opts,next); }else{ @@ -112,19 +112,18 @@ module.exports = { database : "postgres" }); - pg.connect(defaultDbOpts, function (err, client, done) { + const client = new Client(defaultDbOpts); + + client.connect(function (err) { if (err) { - console.log(err); - done(); + console.log(err); return next(err); } client.query('CREATE DATABASE ' + opts.database, function (err, res) { if (err) { - console.log("Failed to create `" + opts.database +"`",err); - done(); + console.log("Failed to create `" + opts.database +"`",err); return next(err); - } console.log("Database `" + opts.database + "` created! Continue..."); diff --git a/package.json b/package.json index 2ba449700..004bf4063 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "passport": "0.3.0", "passport-ldapauth": "^2.1.4", "passport-local": "1.0.0", + "pg": "^8.7.1", "rc": "^1.2.8", "sails": "~0.12.14", "sails-disk": "^0.10.10",