@devotis/db-migrate-mssql
Advanced tools
Comparing version 1.1.2 to 1.1.3
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
@@ -9,5 +10,12 @@ | ||
## [1.1.3] - 2020-03-18 | ||
### Fixed | ||
- mssql syntax for adding a column #3 | ||
## [1.1.2] - 2019-10-24 | ||
### Changed | ||
- Explain in readme how to install this as an alias for `db-migrate-mssq`. | ||
@@ -18,2 +26,3 @@ | ||
### Changed | ||
- Documented installation | ||
@@ -24,2 +33,3 @@ | ||
### Added | ||
- Each migration is run within a transaction. Failed sql means migration did not happen. (PR #2) ([jpinkster](https://github.com/jpinkster)) | ||
@@ -30,7 +40,9 @@ | ||
### Fixed | ||
- Invalid object name '[your-schema].migrations'. Was caused by checking the `recordset` property that is already removed by the `all` and `runSql` functions. | ||
## [1.0.0] - 2019-04-13 | ||
I've built db-migrate-mssql today. I started from a fork of https://github.com/db-migrate/pg . Took me about half a day to build it, and it's working. Without transactions for now. I'm sure there's room for improvement though. If you want to try, run: yarn add @devotis/db-migrate-mssql | ||
I've not adapted the tests from pg to mssql yet, so no guarantees, but I'm able to migrate up and down. I tried only runSql thus far. |
27
index.js
@@ -276,2 +276,29 @@ var util = require('util'); | ||
addColumn: function(tableName, columnName, columnSpec, callback) { | ||
var columnSpec = this.normalizeColumnSpec(columnSpec); | ||
this._prepareSpec(columnName, columnSpec, {}, tableName); | ||
var def = this.createColumnDef(columnName, columnSpec, {}, tableName); | ||
var extensions = ''; | ||
var self = this; | ||
if (typeof this._applyAddColumnExtension === 'function') { | ||
extensions = this._applyAddColumnExtension(def, tableName, columnName); | ||
} | ||
var sql = util.format( | ||
'ALTER TABLE %s ADD %s %s', | ||
this.escapeDDL(tableName), | ||
def.constraints, | ||
extensions | ||
); | ||
return this.runSql(sql) | ||
.then(function() { | ||
var callbacks = def.callbacks || []; | ||
if (def.foreignKey) callbacks.push(def.foreignKey); | ||
return self.recurseCallbackArray(callbacks); | ||
}) | ||
.nodeify(callback); | ||
}, | ||
removeColumn: function (tableName, columnName, callback) { | ||
@@ -278,0 +305,0 @@ var sql = util.format( |
{ | ||
"name": "@devotis/db-migrate-mssql", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A mssql driver for db-migrate", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
24338
583