Socket
Socket
Sign inDemoInstall

db-migrate

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db-migrate - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

9

CHANGELOG.md

@@ -30,2 +30,9 @@ ## 0.1.0

- Fix migration table creation error on PostgreSQL >= 9.1 #20
- Document length property on columns #19 (via Glen Mailer)
- Document length property on columns #19 (via Glen Mailer)
## 0.1.5
Fix:
- Add testing for all supported database drivers
- Fix dropTable on PostgreSQL #21
- Implement removeColumn and changeColumn for MySQL

6

lib/driver/base.js

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

case type.STRING:
return 'TEXT';
return 'VARCHAR(255)';
case type.TEXT:

@@ -54,3 +54,3 @@ return 'TEXT';

ifNotExists: true
}
};
this.createTable('migrations', options, callback);

@@ -105,3 +105,3 @@ },

dropTable: function(tableName, options, callback) {
if (typeof(options) == 'function') {
if (arguments.length < 3) {
callback = options;

@@ -108,0 +108,0 @@ options = {};

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

constraint.push('DEFAULT');
constraint.push(spec.defaultValue);
if (typeof spec.defaultValue == 'string'){
constraint.push("'" + spec.defaultValue + "'");
} else {
constraint.push(spec.defaultValue);
}
}

@@ -43,10 +48,15 @@

//removeColumn: function(tableName, columnName, callback) {
//},
removeColumn: function(tableName, columnName, callback) {
var sql = util.format('ALTER TABLE %s DROP COLUMN %s', tableName, columnName);
this.runSql(sql, callback);
},
//renameColumn: function(tableName, oldColumnName, newColumnName, callback) {
//};
// renameColumn: function(tableName, oldColumnName, newColumnName, callback) {
// },
//changeColumn: function(tableName, columnName, columnSpec, callback) {
//},
changeColumn: function(tableName, columnName, columnSpec, callback) {
var constraint = this.createColumnDef(columnName, columnSpec);
var sql = util.format('ALTER TABLE %s CHANGE COLUMN %s %s', tableName, columnName, constraint);
this.runSql(sql, callback);
},

@@ -53,0 +63,0 @@ runSql: function() {

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

} else {
constraint.push(spec.defaultValue);
constraint.push(spec.defaultValue);
}

@@ -100,3 +100,3 @@ }

renameTable: function(tableName, newTableName, callback) {
var sql = util.format('ALTER TABLE %s RENAME TABLE TO %s', tableName, newTableName);
var sql = util.format('ALTER TABLE %s RENAME TO %s', tableName, newTableName);
this.runSql(sql, callback);

@@ -112,8 +112,37 @@ },

var sql = util.format("ALTER TABLE %s RENAME COLUMN %s TO %s", tableName, oldColumnName, newColumnName);
this.runSql(sql, callback)
this.runSql(sql, callback);
},
//changeColumn: function(tableName, columnName, columnSpec, callback) {
//},
changeColumn: function(tableName, columnName, columnSpec, callback) {
setNotNull.call(this);
function setNotNull() {
var setOrDrop = columnSpec.notNull === true ? 'SET' : 'DROP';
var sql = util.format("ALTER TABLE %s ALTER COLUMN %s %s NOT NULL", tableName, columnName, setOrDrop);
this.runSql(sql, setDefaultValue.bind(this));
}
function setDefaultValue(err) {
if (err) {
return callback(err);
}
var sql;
if (columnSpec.defaultValue !== undefined) {
var defaultValue = null;
if (typeof columnSpec.defaultValue == 'string'){
defaultValue = "'" + columnSpec.defaultValue + "'";
} else {
defaultValue = spec.defaultValue;
}
sql = util.format("ALTER TABLE %s ALTER COLUMN %s SET DEFAULT %s", tableName, columnName, defaultValue);
} else {
sql = util.format("ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT", tableName, columnName);
}
this.runSql(sql, callback);
}
},
runSql: function() {

@@ -120,0 +149,0 @@ params = arguments;

@@ -14,3 +14,3 @@ {

],
"version": "0.1.4",
"version": "0.1.5",
"engines": {

@@ -44,3 +44,3 @@ "node": ">=0.6.0"

"vows": "~0.6.2",
"db-info": "~0.0.1"
"db-meta": "~0.3.2"
},

@@ -47,0 +47,0 @@ "scripts": {

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