}
+ /**
+ * Remove noisy _types from results.
+ * @param {object[]} results multiResult response
+ * @returns {object[]} scrubbed results
+ */
+ static _multiResultLog(results) {
+ const logResults = structuredClone(results);
+ for (const result of logResults) {
+ delete result._types;
+ }
+ return logResults;
+ }
+
+
async _tableExists(tableName, schema) {
if (schema) {
return this.db.oneOrNone('SELECT table_name FROM information_schema.tables WHERE table_name=$(tableName) AND table_schema=$(schema)', { tableName, schema });
let metaExists = await this._tableExists(metaVersionTable, this.pgSchema);
if (!metaExists) {
const results = await this._createMetaVersionTable();
- this.logger.debug(_scope, 'created meta version table', { results });
+ this.logger.debug(_scope, 'created meta version table', { results: this.constructor._multiResultLog(results) });
metaExists = await this._tableExists(metaVersionTable, this.pgSchema);
/* istanbul ignore if */
if (!metaExists) {
const fPath = path.join(sqlPath, 'sql', 'schema', v, 'apply.sql');
const migrationSql = _queryFile(fPath);
const results = await this.db.multiResult(migrationSql);
- this.logger.debug(_scope, 'executed migration sql', { version: v, results });
+ this.logger.debug(_scope, 'executed migration sql', { version: v, results: this.constructor._multiResultLog(results) });
this.logger.info(_scope, 'applied migration', { version: v });
}
}
--- /dev/null
+'use strict';
+
+module.exports = {
+ multiResultResponse: [
+ {
+ "command": "BEGIN",
+ "rowCount": null,
+ "oid": null,
+ "rows": [],
+ "fields": [],
+ "_types": {
+ "_types": {
+ "arrayParser": {},
+ "builtins": {
+ "BOOL": 16,
+ "BYTEA": 17,
+ "CHAR": 18,
+ "INT8": 20,
+ "INT2": 21,
+ "INT4": 23,
+ "REGPROC": 24,
+ "TEXT": 25,
+ "OID": 26,
+ "TID": 27,
+ "XID": 28,
+ "CID": 29,
+ "JSON": 114,
+ "XML": 142,
+ "PG_NODE_TREE": 194,
+ "SMGR": 210,
+ "PATH": 602,
+ "POLYGON": 604,
+ "CIDR": 650,
+ "FLOAT4": 700,
+ "FLOAT8": 701,
+ "ABSTIME": 702,
+ "RELTIME": 703,
+ "TINTERVAL": 704,
+ "CIRCLE": 718,
+ "MACADDR8": 774,
+ "MONEY": 790,
+ "MACADDR": 829,
+ "INET": 869,
+ "ACLITEM": 1033,
+ "BPCHAR": 1042,
+ "VARCHAR": 1043,
+ "DATE": 1082,
+ "TIME": 1083,
+ "TIMESTAMP": 1114,
+ "TIMESTAMPTZ": 1184,
+ "INTERVAL": 1186,
+ "TIMETZ": 1266,
+ "BIT": 1560,
+ "VARBIT": 1562,
+ "NUMERIC": 1700,
+ "REFCURSOR": 1790,
+ "REGPROCEDURE": 2202,
+ "REGOPER": 2203,
+ "REGOPERATOR": 2204,
+ "REGCLASS": 2205,
+ "REGTYPE": 2206,
+ "UUID": 2950,
+ "TXID_SNAPSHOT": 2970,
+ "PG_LSN": 3220,
+ "PG_NDISTINCT": 3361,
+ "PG_DEPENDENCIES": 3402,
+ "TSVECTOR": 3614,
+ "TSQUERY": 3615,
+ "GTSVECTOR": 3642,
+ "REGCONFIG": 3734,
+ "REGDICTIONARY": 3769,
+ "JSONB": 3802,
+ "REGNAMESPACE": 4089,
+ "REGROLE": 4096
+ }
+ },
+ "text": {},
+ "binary": {}
+ },
+ "RowCtor": null,
+ "rowAsArray": false,
+ "_prebuiltEmptyResultObject": null
+ },
+ {
+ "command": "COMMIT",
+ "rowCount": null,
+ "oid": null,
+ "rows": [],
+ "fields": [],
+ "_types": {
+ "_types": {
+ "arrayParser": {},
+ "builtins": {
+ "BOOL": 16,
+ "BYTEA": 17,
+ "CHAR": 18,
+ "INT8": 20,
+ "INT2": 21,
+ "INT4": 23,
+ "REGPROC": 24,
+ "TEXT": 25,
+ "OID": 26,
+ "TID": 27,
+ "XID": 28,
+ "CID": 29,
+ "JSON": 114,
+ "XML": 142,
+ "PG_NODE_TREE": 194,
+ "SMGR": 210,
+ "PATH": 602,
+ "POLYGON": 604,
+ "CIDR": 650,
+ "FLOAT4": 700,
+ "FLOAT8": 701,
+ "ABSTIME": 702,
+ "RELTIME": 703,
+ "TINTERVAL": 704,
+ "CIRCLE": 718,
+ "MACADDR8": 774,
+ "MONEY": 790,
+ "MACADDR": 829,
+ "INET": 869,
+ "ACLITEM": 1033,
+ "BPCHAR": 1042,
+ "VARCHAR": 1043,
+ "DATE": 1082,
+ "TIME": 1083,
+ "TIMESTAMP": 1114,
+ "TIMESTAMPTZ": 1184,
+ "INTERVAL": 1186,
+ "TIMETZ": 1266,
+ "BIT": 1560,
+ "VARBIT": 1562,
+ "NUMERIC": 1700,
+ "REFCURSOR": 1790,
+ "REGPROCEDURE": 2202,
+ "REGOPER": 2203,
+ "REGOPERATOR": 2204,
+ "REGCLASS": 2205,
+ "REGTYPE": 2206,
+ "UUID": 2950,
+ "TXID_SNAPSHOT": 2970,
+ "PG_LSN": 3220,
+ "PG_NDISTINCT": 3361,
+ "PG_DEPENDENCIES": 3402,
+ "TSVECTOR": 3614,
+ "TSQUERY": 3615,
+ "GTSVECTOR": 3642,
+ "REGCONFIG": 3734,
+ "REGDICTIONARY": 3769,
+ "JSONB": 3802,
+ "REGNAMESPACE": 4089,
+ "REGROLE": 4096
+ }
+ },
+ "text": {},
+ "binary": {}
+ },
+ "RowCtor": null,
+ "rowAsArray": false,
+ "_prebuiltEmptyResultObject": null
+ }
+ ],
+};
\ No newline at end of file
const DBErrors = require('../../lib/errors');
const { nop, itChecksImplementation } = require('../helpers');
const { StubLogger } = require('@squeep/test-helper');
+const { multiResultResponse } = require('../data/postgres');
describe('Postgres Creator', function () {
let db, options, stubLogger;
describe('_initTables', function () {
beforeEach(function () {
- sinon.stub(db.db, 'multiResult').resolves();
+ sinon.stub(db.db, 'multiResult').resolves(multiResultResponse);
sinon.stub(db, '_currentSchema');
sinon.stub(db, '_tableExists');
sinon.stub(fs, 'readdirSync').returns([]);