db-migrate
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -154,1 +154,7 @@ ## 0.1.0 | ||
- Provide close callback for MySQL driver #107 (via @codeaholics) | ||
## 0.5.2 | ||
Fix: | ||
- Add ability to create camel-cased column names for PostgreSQL #111 (via @virpool) | ||
- Add ability to make a unique index #110 (via @codeaholics) |
@@ -149,7 +149,12 @@ var util = require('util'); | ||
addIndex: function(tableName, indexName, columns, callback) { | ||
addIndex: function(tableName, indexName, columns, unique, callback) { | ||
if (typeof(unique) === 'function') { | ||
callback = unique; | ||
unique = false; | ||
} | ||
if (!Array.isArray(columns)) { | ||
columns = [columns]; | ||
} | ||
var sql = util.format('CREATE INDEX %s ON %s (%s)', indexName, tableName, columns.join(', ')); | ||
var sql = util.format('CREATE %s INDEX %s ON %s (%s)', (unique ? 'UNIQUE' : ''), indexName, tableName, columns.join(', ')); | ||
this.runSql(sql, callback); | ||
@@ -156,0 +161,0 @@ }, |
@@ -27,3 +27,3 @@ var util = require('util'); | ||
var constraint = this.createColumnConstraint(spec, options); | ||
return [name, type, len, constraint].join(' '); | ||
return ['"' + name + '"', type, len, constraint].join(' '); | ||
}, | ||
@@ -30,0 +30,0 @@ |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"engines": { | ||
@@ -17,0 +17,0 @@ "node": ">=0.6.0" |
@@ -27,2 +27,3 @@ # db-migrate | ||
--config Location of the database.json file. [default: "./database.json"] | ||
--force-exit Call system.exit() after migration run [default: false] | ||
``` | ||
@@ -334,3 +335,3 @@ | ||
### addIndex(tableName, indexName, columns, callback) | ||
### addIndex(tableName, indexName, columns, [unique], callback) | ||
@@ -344,2 +345,3 @@ Add an index | ||
* columns - an array of column names contained in the index | ||
* unique - whether the index is unique (optional, default false) | ||
* callback(err) - callback that will be invoked after adding the index | ||
@@ -346,0 +348,0 @@ |
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
93021
1541
426