Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

larvitdbmigration

Package Overview
Dependencies
Maintainers
2
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

larvitdbmigration - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

dbType/mariadb.js

148

dbType/elasticsearch.js

@@ -6,11 +6,18 @@ 'use strict';

async = require('async'),
log = require('winston'),
fs = require('fs');
function getLock(retries, cb) {
const logPrefix = topLogPrefix + 'getLock() - indexName: "' + this.options.tableName + '" - ',
that = this,
es = that.options.dbDriver,
esUri = 'http://' + es.transport._config.host;
function Driver(options) {
const that = this;
that.options = options || {};
if ( ! that.options.indexName) {
throw new Error('Missing required option "indexName"');
}
}
Driver.prototype.getLock = function getLock(retries, cb) {
const logPrefix = topLogPrefix + 'getLock() - indexName: "' + this.options.indexName + '" - ',
that = this;
if (typeof retries === 'function') {

@@ -21,3 +28,3 @@ cb = retries;

log.debug(logPrefix + 'Started');
that.log.debug(logPrefix + 'Started');

@@ -27,7 +34,7 @@ // Source: https://www.elastic.co/guide/en/elasticsearch/guide/current/concurrency-solutions.html

'method': 'PUT',
'uri': esUri + '/fs/lock/global/_create',
'uri': that.options.url + '/fs/lock/global/_create',
'body': '{}'
}, function (err, response) {
if (err) {
log.error(logPrefix + 'Can not get lock on ' + esUri + '/fs/lock/global/_create');
that.log.error(logPrefix + 'Can not get lock on ' + that.options.url + '/fs/lock/global/_create');
return cb(err);

@@ -38,5 +45,5 @@ }

if (retries < 100) {
log.info(logPrefix + 'Another process is running the migrations, retry nr: ' + retries + ', wait and try again soon. StatusCode: ' + response.statusCode);
that.log.info(logPrefix + 'Another process is running the migrations, retry nr: ' + retries + ', wait and try again soon. StatusCode: ' + response.statusCode);
} else {
log.warn(logPrefix + 'Another process is running the migrations, retry nr: ' + retries + ', wait and try again soon. StatusCode: ' + response.statusCode);
that.log.warn(logPrefix + 'Another process is running the migrations, retry nr: ' + retries + ', wait and try again soon. StatusCode: ' + response.statusCode);
}

@@ -50,19 +57,17 @@

log.verbose(logPrefix + 'Locked!');
that.log.verbose(logPrefix + 'Locked!');
cb();
});
}
};
function rmLock(cb) {
const logPrefix = topLogPrefix + 'rmLock() - indexName: "' + this.options.tableName + '" - ',
that = this,
es = that.options.dbDriver,
esUri = 'http://' + es.transport._config.host;
Driver.prototype.rmLock = function rmLock(cb) {
const logPrefix = topLogPrefix + 'rmLock() - indexName: "' + this.options.indexName + '" - ',
that = this;
log.debug(logPrefix + 'Started');
that.log.debug(logPrefix + 'Started');
request.delete(esUri + '/fs/lock/global', function (err, response) {
request.delete(that.options.url + '/fs/lock/global', function (err, response) {
if (err) {
log.error(logPrefix + 'Can not clear lock on ' + esUri + '/fs/lock/global');
that.log.error(logPrefix + 'Can not clear lock on ' + that.options.url + '/fs/lock/global');
return cb(err);

@@ -73,37 +78,35 @@ }

const err = new Error('Lock could not be removed. StatusCode: ' + response.statusCode);
log.warn(logPrefix + err.message);
that.log.warn(logPrefix + err.message);
return cb(err);
}
log.verbose(logPrefix + 'Unlocked!');
that.log.verbose(logPrefix + 'Unlocked!');
cb();
});
}
};
function run(cb) {
Driver.prototype.run = function run(cb) {
const logPrefix = topLogPrefix + 'run() - indexName: "' + this.options.tableName + '" - ',
indexName = this.options.tableName,
indexName = this.options.indexName,
tasks = [],
that = this,
es = that.options.dbDriver,
esUri = 'http://' + es.transport._config.host;
that = this;
let curDoc;
log.debug(logPrefix + 'Started');
that.log.debug(logPrefix + 'Started');
function getDoc(cb) {
const subLogPrefix = logPrefix + 'getDoc() - ',
uri = esUri + '/' + indexName + '/' + indexName + '/1';
uri = that.options.url + '/' + indexName + '/' + indexName + '/1';
log.debug(subLogPrefix + 'Running for ' + uri);
that.log.debug(subLogPrefix + 'Running for ' + uri);
request(uri, function (err, response, body) {
if (err) {
log.error(subLogPrefix + 'GET ' + uri + ' failed, err: ' + err.message);
that.log.error(subLogPrefix + 'GET ' + uri + ' failed, err: ' + err.message);
return cb(err);
}
log.debug(subLogPrefix + 'GET ' + uri + ' ' + response.statusCode + ' ' + response.statusMessage);
that.log.debug(subLogPrefix + 'GET ' + uri + ' ' + response.statusCode + ' ' + response.statusMessage);

@@ -114,3 +117,3 @@ if (response.statusCode === 200) {

} catch (err) {
log.error(subLogPrefix + 'GET ' + uri + ' invalid JSON in body, err: ' + err.message + ' string: "' + body + '"');
that.log.error(subLogPrefix + 'GET ' + uri + ' invalid JSON in body, err: ' + err.message + ' string: "' + body + '"');
cb(err);

@@ -133,9 +136,9 @@ }

const subLogPrefix = logPrefix + 'indexName: "' + indexName + '" - ',
uri = esUri + '/' + indexName;
uri = that.options.url + '/' + indexName;
log.debug(subLogPrefix + 'Crating index if it did not exist');
that.log.debug(subLogPrefix + 'Crating index if it did not exist');
request.head(uri, function (err, response) {
if (err) {
log.error(subLogPrefix + 'HEAD ' + uri + ' failed, err: ' + err.message);
that.log.error(subLogPrefix + 'HEAD ' + uri + ' failed, err: ' + err.message);
return cb(err);

@@ -145,11 +148,11 @@ }

if (response.statusCode === 200) {
log.debug(subLogPrefix + 'Index already exists');
that.log.debug(subLogPrefix + 'Index already exists');
return cb();
} else if (response.statusCode !== 404) {
const err = new Error('HEAD ' + uri + ' unexpected statusCode: ' + response.statusCode);
log.error(subLogPrefix + err.message);
that.log.error(subLogPrefix + err.message);
return cb(err);
}
log.debug(subLogPrefix + 'Index does not exist, create it');
that.log.debug(subLogPrefix + 'Index does not exist, create it');

@@ -159,3 +162,3 @@ // If we arrive here its a 404 - create it!

if (err) {
log.error(subLogPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
that.log.error(subLogPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
return cb(err);

@@ -166,7 +169,7 @@ }

const err = new Error('PUT ' + uri + ', Unexpected statusCode: ' + response.statusCode);
log.error(subLogPrefix + err.message);
that.log.error(subLogPrefix + err.message);
return cb(err);
}
log.debug(subLogPrefix + 'Created!');
that.log.debug(subLogPrefix + 'Created!');

@@ -180,3 +183,3 @@ cb();

tasks.push(function (cb) {
const uri = esUri + '/' + indexName + '/' + indexName + '/1';
const uri = that.options.url + '/' + indexName + '/' + indexName + '/1';

@@ -187,7 +190,7 @@ getDoc(function (err, response) {

if (response.statusCode === 404) {
log.debug(logPrefix + 'Create database version document');
that.log.debug(logPrefix + 'Create database version document');
request.put({'url': uri, 'json': {'version': 0, 'status': 'finnished'}}, function (err, response) {
if (err) {
log.error(logPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
that.log.error(logPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
return cb(err);

@@ -198,7 +201,7 @@ }

const err = new Error('Failed to create document, statusCode: ' + response.statusCode);
log.error(logPrefix + err.message);
that.log.error(logPrefix + err.message);
return cb(err);
}
log.verbose(logPrefix + 'Database version document created');
that.log.verbose(logPrefix + 'Database version document created');

@@ -208,7 +211,7 @@ getDoc(cb);

} else if (response.statusCode === 200) {
log.debug(logPrefix + 'Database version document already exists');
that.log.debug(logPrefix + 'Database version document already exists');
cb();
} else {
const err = new Error('Unexpected statusCode when getting database version document: ' + response.statusCode);
log.error(logPrefix + err.message);
that.log.error(logPrefix + err.message);
return cb(err);

@@ -224,3 +227,3 @@ }

} catch (err) {
log.error(logPrefix + 'Error from driver: ' + err.message);
that.log.error(logPrefix + 'Error from driver: ' + err.message);
cb(err);

@@ -238,15 +241,13 @@ }

function runScripts(startVersion, cb) {
Driver.prototype.runScripts = function runScripts(startVersion, cb) {
const migrationScriptsPath = this.options.migrationScriptsPath,
indexName = this.options.tableName,
logPrefix = topLogPrefix + 'runScripts() - indexName: "' + this.options.tableName + '" - ',
indexName = this.options.indexName,
logPrefix = topLogPrefix + 'runScripts() - indexName: "' + this.options.indexName + '" - ',
tasks = [],
that = this,
es = this.options.dbDriver,
esUri = 'http://' + es.transport._config.host,
uri = esUri + '/' + indexName + '/' + indexName + '/1';
uri = that.options.url + '/' + indexName + '/' + indexName + '/1';
let scriptFound = false;
log.verbose(logPrefix + 'Started with startVersion: "' + startVersion + '" in path: "' + migrationScriptsPath + '" on esUri: ' + esUri);
that.log.verbose(logPrefix + 'Started with startVersion: "' + startVersion + '" in path: "' + migrationScriptsPath + '" on options.url: ' + that.options.url);

@@ -256,3 +257,3 @@ // Update db_version status

if (fs.existsSync(migrationScriptsPath + '/' + startVersion + '.js')) {
log.info(logPrefix + 'Found js migration script #' + startVersion + ', running it now.');
that.log.info(logPrefix + 'Found js migration script #' + startVersion + ', running it now.');

@@ -263,3 +264,3 @@ scriptFound = true;

if (err) {
log.error(logPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
that.log.error(logPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
return cb(err);

@@ -270,3 +271,3 @@ }

const err = new Error('PUT ' + uri + ' statusCode: ' + response.statusCode);
log.error(logPrefix + err.message);
that.log.error(logPrefix + err.message);
return cb(err);

@@ -290,7 +291,7 @@ }

log.error(logPrefix + 'Got error running migration script ' + migrationScriptsPath + '/' + startVersion + '.js' + ': ' + err.message);
that.log.error(logPrefix + 'Got error running migration script ' + migrationScriptsPath + '/' + startVersion + '.js' + ': ' + err.message);
request.put({'url': uri, 'json': {'version': startVersion, 'status': 'failed'}}, function (err, response) {
if (err) {
log.error(logPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
that.log.error(logPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
return cb(err);

@@ -301,3 +302,3 @@ }

const err = new Error('PUT ' + uri + ' statusCode: ' + response.statusCode);
log.error(logPrefix + err.message);
that.log.error(logPrefix + err.message);
return cb(err);

@@ -311,7 +312,7 @@ }

log.debug(logPrefix + 'Js migration script #' + startVersion + ' ran. Updating database version and moving on.');
that.log.debug(logPrefix + 'Js migration script #' + startVersion + ' ran. Updating database version and moving on.');
request.put({'url': uri, 'json': {'version': startVersion, 'status': 'finnished'}}, function (err, response) {
if (err) {
log.error(logPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
that.log.error(logPrefix + 'PUT ' + uri + ' failed, err: ' + err.message);
return cb(err);

@@ -322,3 +323,3 @@ }

const err = new Error('PUT ' + uri + ' statusCode: ' + response.statusCode);
log.error(logPrefix + err.message);
that.log.error(logPrefix + err.message);
return cb(err);

@@ -335,3 +336,3 @@ }

} catch (err) {
log.error(logPrefix + 'Uncaught error: ' + err.message);
that.log.error(logPrefix + 'Uncaught error: ' + err.message);
return cb(err);

@@ -347,3 +348,3 @@ }

log.info(logPrefix + 'Database migrated and done. Final version is ' + (startVersion - 1));
that.log.info(logPrefix + 'Database migrated and done. Final version is ' + (startVersion - 1));

@@ -353,7 +354,4 @@ // If we end up here, it means there are no more migration scripts to run

});
}
};
exports.getLock = getLock;
exports.rmLock = rmLock;
exports.run = run;
exports.runScripts = runScripts;
exports = module.exports = Driver;
'use strict';
const topLogPrefix = 'larvitdbmigration: index.js - ',
log = require('winston'),
fs = require('fs');
Lutils = require('larvitutils'),
lutils = new Lutils();

@@ -15,39 +15,37 @@ function DbMigration(options) {

that.options = options = options || {};
that.options = options = options || {};
if (options.tableName === undefined) options.tableName = 'db_version';
if (options.migrationScriptsPath === undefined) options.migrationScriptsPath = './dbmigration';
if (options.dbType === undefined) {
throw new Error('Missing options.dbType');
if ( ! that.options.log) {
that.options.log = new lutils.Log();
}
that.dbTypeFile = __dirname + '/dbType/' + options.dbType + '.js';
that.log = that.options.log;
if ( ! fs.existsSync(that.dbTypeFile)) {
throw new Error('Invalid options.dbType "' + options.dbType + '", missing file: "' + dbTypeFile + '"');
}
if (options.tableName === undefined) options.tableName = 'db_version';
if (options.indexName === undefined) options.indexName = 'db_version';
if (options.migrationScriptsPath === undefined) options.migrationScriptsPath = './dbmigration';
if (options.dbType !== 'larvitdb' && options.dbType !== 'elasticsearch') {
throw new Error('Invalid options.dbType: "' + options.dbType + '"');
if (options.dbType !== 'elasticsearch' && options.dbType !== 'mariadb') {
throw new Error('Only dbType "elasticsearch" and "mariadb" are supported, please choose one');
}
if (options.dbDriver === undefined) {
throw new Error('Missing options.dbDriver');
// Resolve ./ paths to be relative to application path
if (that.options.migrationScriptsPath.substring(0, 2) === './') {
that.options.migrationScriptsPath = process.cwd() + '/' + that.options.migrationScriptsPath.substring(2);
}
log.verbose(logPrefix + 'Started with dbType: "' + options.dbType + '", tableName: "' + options.tableName + '", migrationScriptsPath: "' + options.migrationScriptsPath + '"');
that.dbTypeFile = __dirname + '/dbType/' + options.dbType + '.js';
that.DbType = require(that.dbTypeFile);
that.dbType = new that.DbType(that.options);
that.dbType.log = that.log;
// Resolve ./ paths to be relative to application path
if (options.migrationScriptsPath.substring(0, 2) === './') {
options.migrationScriptsPath = process.cwd() + '/' + options.migrationScriptsPath.substring(2);
}
that.log.verbose(logPrefix + 'Started with dbType: "' + that.options.dbType + '", tableName/indexName: "' + (that.options.tableName || that.options.indexName) + '", migrationScriptsPath: "' + that.options.migrationScriptsPath + '"');
// Set functions from dbDriver
that.getLock = require(that.dbTypeFile).getLock;
that.rmLock = require(that.dbTypeFile).rmLock;
that.run = require(that.dbTypeFile).run;
that.runScripts = require(that.dbTypeFile).runScripts;
// Set functions from the dirver
that.getLock = that.dbType.getLock;
that.rmLock = that.dbType.rmLock;
that.run = that.dbType.run;
that.runScripts = that.dbType.runScripts;
}
exports = module.exports = DbMigration;
{
"name": "larvitdbmigration",
"version": "4.0.0",
"author": {

@@ -11,16 +13,14 @@ "name": "Mikael 'Lilleman' Göransson",

"async": "^2.0.1",
"elasticsearch": "^15.0.0",
"json-stringify-safe": "^5.0.1",
"larvitdb": "^2.0.0",
"larvitutils": "^1.1.1",
"larvitutils": "^2.0.0",
"lodash": "^4.7.0",
"mysql2": "^1.3.3",
"request": "^2.81.0",
"winston": "^2.2.0"
"request": "^2.81.0"
},
"description": "node.js database migration tool",
"devDependencies": {
"eslint": "^5.2.0",
"mocha": "^5.1.1",
"mocha-eslint": "^4.1.0"
"larvitdb": "2.0.0",
"eslint": "5.3.0",
"mocha": "5.2.0",
"mocha-eslint": "4.1.0",
"mysql2": "1.6.1"
},

@@ -35,3 +35,2 @@ "keywords": [

"main": "index.js",
"name": "larvitdbmigration",
"repository": {

@@ -41,3 +40,2 @@ "url": "https://github.com/larvit/larvitdbmigration",

},
"version": "3.0.0",
"readmeFilename": "README.md",

@@ -44,0 +42,0 @@ "scripts": {

@@ -9,3 +9,3 @@ [![Build Status](https://travis-ci.org/larvit/larvitdbmigration.svg?branch=master)](https://travis-ci.org/larvit/larvitdbmigration) [![Dependencies](https://david-dm.org/larvit/larvitdbmigration.svg)](https://david-dm.org/larvit/larvitdbmigration.svg)

* MariaDB(/MySQL)
* MariaDB (and MySQL)
* Elasticsearch

@@ -38,2 +38,4 @@

options = {},
winston = require('winston'),
log = winston.createLogger({'transports': [new winston.transports.Console()]}),
db = require('larvitdb');

@@ -50,8 +52,9 @@

options.dbType = 'larvitdb';
options.dbType = 'mariadb';
options.dbDriver = db;
options.tableName = 'db_version'; // Optional - used as index name for elasticsearch
options.migrationScriptsPath = './dbmigration'; // Optional
options.log = log; // Optional, will use log.silly(), log.debug(), log.verbose(), log.info(), log.warn() and log.error() if given.
dbMigration = new DbMigration(options);
dbMigration = new DbMigration(options);

@@ -70,6 +73,6 @@ dbMigration.run(function (err) {

const elasticsearch = require('elasticsearch'),
DbMigration = require('larvitdbmigration'),
const DbMigration = require('larvitdbmigration'),
options = {},
es = new elasticsearch.Client({'host': '127.0.0.1:9200'});
winston = require('winston'),
log = winston.createLogger({'transports': [new winston.transports.Console()]});

@@ -79,5 +82,6 @@ let dbMigration;

options.dbType = 'elasticsearch';
options.dbDriver = es;
options.tableName = 'db_version'; // Optional - used as index name
options.url = 'http://127.0.0.1:9200';
options.indexName = 'db_version'; // Optional
options.migrationScriptsPath = './dbmigration'; // Optional
options.log = log; // Optional, will use log.silly(), log.debug(), log.verbose(), log.info(), log.warn() and log.error() if given.

@@ -124,15 +128,16 @@ dbMigration = new DbMigration(options);

const request = require('request');
exports = module.exports = function (cb) {
const es = this.options.dbDriver;
const that = this;
es.indices.putMapping({
'index': 'foo',
'type': 'bar',
request({
'url': that.options.url + '/some_index/_mapping/some_type,
'json': true,
'method': 'PUT',
'body': {
'bar': {
'properties': {
'names': {
'type': 'string',
'position_increment_gap': 100
}
'properties': {
'names': {
'type': 'string',
'position_increment_gap': 100
}

@@ -139,0 +144,0 @@ }

'use strict';
const elasticsearch = require('elasticsearch'),
DbMigration = require(__dirname + '/../index.js'),
const DbMigration = require(__dirname + '/../index.js'),
request = require('request'),
assert = require('assert'),
lUtils = require('larvitutils'),
Lutils = require('larvitutils'),
lutils = new Lutils(),
async = require('async'),
path = require('path'),
log = require('winston'),
log = new lutils.Log('silence!!!'),
db = require('larvitdb'),

@@ -15,8 +15,4 @@ fs = require('fs');

let mariaDbConf,
esConf,
es;
esConf;
// Set up winston
log.remove(log.transports.Console);
before(function (done) {

@@ -28,17 +24,22 @@ const tasks = [];

if (process.env.ESCONFFILE === undefined) {
esConfFile = __dirname + '/../config/es_test.json';
} else {
esConfFile = process.env.ESCONFFILE;
}
// Set conf file paths
tasks.push(function (cb) {
if (process.env.ESCONFFILE === undefined) {
esConfFile = __dirname + '/../config/es_test.json';
} else {
esConfFile = process.env.ESCONFFILE;
}
if (process.env.DBCONFFILE === undefined) {
mariaDbConfFile = __dirname + '/../config/db_test.json';
} else {
mariaDbConfFile = process.env.DBCONFFILE;
}
if (process.env.DBCONFFILE === undefined) {
mariaDbConfFile = __dirname + '/../config/db_test.json';
} else {
mariaDbConfFile = process.env.DBCONFFILE;
}
log.verbose('MariaDB config file: "' + mariaDbConfFile + '"');
log.verbose('Elasticsearch config file: "' + esConfFile + '"');
log.verbose('MariaDB config file: "' + mariaDbConfFile + '"');
log.verbose('Elasticsearch config file: "' + esConfFile + '"');
cb();
});
// MariaDb

@@ -87,3 +88,3 @@ tasks.push(function (cb) {

mariaDbConf = require(altMariaDbConfFile);
mariaDbConf = require(altMariaDbConfFile);
runMariaDbSetup(altMariaDbConfFile);

@@ -101,7 +102,11 @@ });

function checkEmptyEs() {
es.cat.indices({'v': true}, function (err, result) {
const reqOptions = {};
reqOptions.url = 'http://' + esConf.clientOptions.host + '/_cat/indices?format=json';
reqOptions.json = true;
request(reqOptions, function (err, response, body) {
if (err) throw err;
// Source: https://www.elastic.co/guide/en/elasticsearch/reference/1.4/_list_all_indexes.html
if (result !== 'health status index uuid pri rep docs.count docs.deleted store.size pri.store.size\n') {
if ( ! Array.isArray(body) || body.length !== 0) {
throw new Error('Database is not empty. To make a test, you must supply an empty database!');

@@ -115,16 +120,2 @@ process.exit(1);

function runEsSetup(esConfFile) {
log.verbose('ES config: ' + JSON.stringify(require(esConfFile)));
es = lUtils.instances.elasticsearch = new elasticsearch.Client(require(esConfFile).clientOptions);
es.ping(function (err) {
if (err) {
log.error(err.message);
process.exit(1);
}
checkEmptyEs();
});
}
fs.stat(esConfFile, function (err) {

@@ -142,8 +133,8 @@ const altEsConfFile = __dirname + '/../config/' + esConfFile;

esConf = require(altEsConfFile);
runEsSetup(altEsConfFile);
esConf = require(altEsConfFile);
checkEmptyEs(altEsConfFile);
});
} else {
esConf = require(esConfFile);
runEsSetup(esConfFile);
esConf = require(esConfFile);
checkEmptyEs(esConfFile);
}

@@ -164,3 +155,9 @@ });

tasks.push(function (cb) {
es.indices.delete({'index': '*'}, cb);
const reqOptions = {};
reqOptions.url = 'http://' + esConf.clientOptions.host + '/_all';
reqOptions.json = true;
reqOptions.method = 'DELETE';
request(reqOptions, cb);
});

@@ -182,10 +179,10 @@

mariaDbConf.migrationScriptsPath = path.join(__dirname, '../testmigrations_mariadb');
mariaDbConf.dbType = 'larvitdb';
mariaDbConf.dbType = 'mariadb';
mariaDbConf.dbDriver = db;
mariaDbConf.log = log;
dbMigrations = new DbMigration(mariaDbConf);
dbMigrations = new DbMigration(mariaDbConf);
dbMigrations.run(function (err) {
if (err) throw err;
done();

@@ -236,6 +233,7 @@ });

mariaDbConf.migrationScriptsPath = path.join(__dirname, '../testmigrations_mariadb_failing');
mariaDbConf.dbType = 'larvitdb';
mariaDbConf.dbType = 'mariadb';
mariaDbConf.dbDriver = db;
mariaDbConf.log = log;
dbMigrations = new DbMigration(mariaDbConf);
dbMigrations = new DbMigration(mariaDbConf);

@@ -254,4 +252,2 @@ dbMigrations.run(function (err) {

describe('Elasticsearch migrations', function () {
let esUri;
this.slow(300);

@@ -262,13 +258,11 @@

esUri = 'http://' + es.transport._config.host;
esConf.dbType = 'elasticsearch';
esConf.url = 'http://' + esConf.clientOptions.host;
esConf.migrationScriptsPath = path.join(__dirname, '../testmigrations_elasticsearch');
esConf.dbType = 'elasticsearch';
esConf.dbDriver = es;
esConf.log = log;
dbMigrations = new DbMigration(esConf);
dbMigrations = new DbMigration(esConf);
dbMigrations.run(function (err) {
if (err) throw err;
done();

@@ -279,3 +273,3 @@ });

it('should check the db_versions index', function (done) {
request(esUri + '/db_version/db_version/1', function (err, response, body) {
request('http://' + esConf.clientOptions.host + '/db_version/db_version/1', function (err, response, body) {
const jsonBody = JSON.parse(body);

@@ -293,3 +287,3 @@

it('should check the foo index', function (done) {
request(esUri + '/foo/bar/666', function (err, response, body) {
request('http://' + esConf.clientOptions.host + '/foo/bar/666', function (err, response, body) {
const jsonBody = JSON.parse(body);

@@ -308,13 +302,11 @@

esUri = 'http://' + es.transport._config.host;
esConf.dbType = 'elasticsearch';
esConf.url = 'http://' + esConf.clientOptions.host;
esConf.migrationScriptsPath = path.join(__dirname, '../testmigrations_elasticsearch');
esConf.dbType = 'elasticsearch';
esConf.dbDriver = es;
esConf.log = log;
dbMigrations = new DbMigration(esConf);
dbMigrations = new DbMigration(esConf);
dbMigrations.run(function (err) {
if (err) throw err;
done();

@@ -321,0 +313,0 @@ });

@@ -7,3 +7,3 @@ 'use strict';

exports = module.exports = function (cb) {
const esUri = 'http://' + this.options.dbDriver.transport._config.host;
const esUri = this.options.url;

@@ -10,0 +10,0 @@ request.put(esUri + '/foo', function (err, response) {

@@ -7,3 +7,3 @@ 'use strict';

exports = module.exports = function (cb) {
const esUri = 'http://' + this.options.dbDriver.transport._config.host;
const esUri = this.options.url;

@@ -10,0 +10,0 @@ request.put({'url': esUri + '/foo/bar/666', 'json': {'blubb': 7}}, function (err, response) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc