Socket
Socket
Sign inDemoInstall

@devotis/db-migrate-mssql

Package Overview
Dependencies
3
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.1.0

6

CHANGELOG.md

@@ -9,3 +9,9 @@ # Changelog

## [1.1.0] - 2019-10-24
### Added
- Each migration is run within a transaction. Failed sql means migration did not happen. (PR #2) ([jpinkster])
## [1.0.1] - 2019-04-14
### Fixed

@@ -12,0 +18,0 @@ - Invalid object name '[your-schema].migrations'. Was caused by checking the `recordset` property that is already removed by the `all` and `runSql` functions.

58

index.js

@@ -7,3 +7,3 @@ var util = require('util');

var MssqlDriver = Base.extend({
init: function (pool, schema, intern) {
init: function (connection, schema, intern) {
this.log = intern.mod.log;

@@ -14,18 +14,6 @@ this.type = intern.mod.type;

this.internals = intern;
this.pool = pool;
this.connection = connection;
this.schema = schema || 'dbo';
},
// startMigration: function (cb) {
// if (!this.internals.notransactions) {
// return this.runSql('BEGIN').nodeify(cb);
// } else return Promise.resolve().nodeify(cb);
// },
//
// endMigration: function (cb) {
// if (!this.internals.notransactions) {
// return this.runSql('COMMIT').nodeify(cb);
// } else return Promise.resolve(null).nodeify(cb);
// },
createColumnDef: function (name, spec, options, tableName) {

@@ -514,13 +502,32 @@ var type =

function (resolve, reject) {
const request = this.pool.request();
if (this.internals.notransactions) {
const request = new this.connection.Request();
if (params[1]) {
for (let i = 0; i < params[1].length; i++) {
request.input(`input_${i + 1}`, params[1][i]);
if (params[1]) {
for (let i = 0; i < params[1].length; i++) {
request.input(`input_${i + 1}`, params[1][i]);
}
}
request.query(params[0]).then(result => {
resolve(result.recordset);
}, reject);
}
else {
const transaction = new this.connection.Transaction();
transaction.begin(() => {
const request = new this.connection.Request(transaction);
request.query(params[0]).then(result => {
resolve(result.recordset);
}, reject);
if (params[1]) {
for (let i = 0; i < params[1].length; i++) {
request.input(`input_${i + 1}`, params[1][i]);
}
}
request.query(params[0]).then(result => {
transaction.commit();
resolve(result.recordset);
}, reject);
})
}
}.bind(this)

@@ -537,3 +544,3 @@ ).nodeify(callback);

function (resolve, reject) {
const request = this.pool.request();
const request = new this.connection.Request();

@@ -553,3 +560,3 @@ request.query(params[0]).then(result => {

}).then(() => {
return this.pool.close();
return this.connection.close();
});

@@ -622,7 +629,6 @@

var db = config.db || new mssql.ConnectionPool(config);
db.connect()
mssql.connect(config)
.then(pool => {
callback(null, new MssqlDriver(db, config.schema, intern));
callback(null, new MssqlDriver(mssql, config.schema, intern));
})

@@ -629,0 +635,0 @@ .catch(err => {

{
"name": "@devotis/db-migrate-mssql",
"version": "1.0.1",
"version": "1.1.0",
"description": "A mssql driver for db-migrate",

@@ -33,3 +33,3 @@ "main": "index.js",

"db-migrate-base": "^1.6.3",
"mssql": "5.0.5"
"mssql": "6.0.0-beta.1"
},

@@ -36,0 +36,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc