db-migrate
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -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) | ||
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98866
30
1385
4
+ Addedmkdirp@~0.3.4
+ Addedmkdirp@0.3.5(transitive)