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.2.3 to 0.2.4

.idea/codeStyleSettings.xml

7

CHANGELOG.md

@@ -66,1 +66,8 @@ ## 0.1.0

- Fix error when using mysql-2.0.0-alpha3 driver #44
## 0.2.4
Fix:
- Use --migrations-dir option when specified #47
- Handle unique constraints in changeColumn() for postgres #46 (via @ryanmeador)

4

index.js

@@ -14,4 +14,4 @@ var driver = require('./lib/driver');

exports.createMigration = function(title, callback) {
var migration = new Migration(title, new Date());
exports.createMigration = function(title, migrationsDir, callback) {
var migration = new Migration(title, migrationsDir, new Date());
migration.write(function(err) {

@@ -18,0 +18,0 @@ if (err) { callback(err); return; }

@@ -119,5 +119,24 @@ var util = require('util');

var sql = util.format("ALTER TABLE %s ALTER COLUMN %s %s NOT NULL", tableName, columnName, setOrDrop);
this.runSql(sql, setDefaultValue.bind(this));
this.runSql(sql, setUnique.bind(this));
}
function setUnique(err) {
if (err) {
callback(err);
}
var sql;
var constraintName = tableName + '_' + columnName + '_unique';
if (columnSpec.unique === true) {
sql = util.format("ALTER TABLE %s ADD CONSTRAINT %s UNIQUE (%s)", tableName, constraintName, columnName);
this.runSql(sql, setDefaultValue.bind(this));
} else if (columnSpec.unique === false) {
sql = util.format("ALTER TABLE %s DROP CONSTRAINT %s", tableName, constraintName);
this.runSql(sql, setDefaultValue.bind(this));
} else {
setDefaultValue.call(this);
}
}
function setDefaultValue(err) {

@@ -124,0 +143,0 @@ if (err) {

@@ -7,4 +7,4 @@ var fs = require('fs');

function formatPath(name) {
return process.cwd() + '/migrations/' + name + '.js';
function formatPath(dir, name) {
return path.join(dir, name + '.js');
}

@@ -68,7 +68,7 @@

Migration = function() {
if (arguments.length == 2) {
if (arguments.length == 3) {
this.title = arguments[0];
this.date = arguments[1];
this.date = arguments[2];
this.name = formatName(this.title, this.date);
this.path = formatPath(this.name);
this.path = formatPath(arguments[1], this.name);
} else if (arguments.length == 1) {

@@ -75,0 +75,0 @@ this.path = arguments[0];

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

],
"version": "0.2.3",
"version": "0.2.4",
"engines": {

@@ -40,3 +40,4 @@ "node": ">=0.6.0"

"async": "~0.1.15",
"semver": "~1.0.14"
"semver": "~1.0.14",
"mkdirp": "~0.3.4"
},

@@ -48,4 +49,4 @@ "devDependencies": {

"scripts": {
"test": "vows"
"test": "node_modules/.bin/vows"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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