db-migrate
Advanced tools
Comparing version 0.5.4 to 0.6.0
@@ -170,1 +170,15 @@ ## 0.1.0 | ||
- Add backticks to MySQL driver #114 (via @mstorgaard) | ||
## 0.6.0 | ||
New Feature: | ||
- Support varargs in runSql, all on mysql driver #119 (via @Gloridea) | ||
- Load Environment Variables specified in config file #118 (via @codyhanson) | ||
- Added CoffeeScript support for migrations #116 (via @DeniSix) | ||
Improvement: | ||
- Added date type for sqlite3 #121 (via @mrcsparker) | ||
Fix: | ||
- Fix postgres issue with camelCased column name definition #125 (via @virpool) | ||
@@ -15,3 +15,3 @@ var driver = require('./lib/driver'); | ||
exports.createMigration = function(title, migrationsDir, callback) { | ||
var migration = new Migration(title, migrationsDir, new Date()); | ||
var migration = new Migration(title + '.js', migrationsDir, new Date()); | ||
migration.write(function(err) { | ||
@@ -18,0 +18,0 @@ if (err) { callback(err); return; } |
@@ -21,6 +21,14 @@ var fs = require('fs'); | ||
for (var env in config) { | ||
if (typeof(config[env]) == "string") | ||
if (typeof(config[env]) == "string") { | ||
exports[env] = parseDatabaseUrl(config[env]); | ||
else | ||
} else { | ||
//Check config entry's for ENV objects | ||
//which will tell us to grab configuration from the environment | ||
for (var configEntry in config[env]) { | ||
if (config[env][configEntry].ENV != null){ | ||
config[env][configEntry] = process.env[config[env][configEntry].ENV]; | ||
} | ||
} | ||
exports[env] = config[env]; | ||
} | ||
} | ||
@@ -27,0 +35,0 @@ |
@@ -8,2 +8,3 @@ module.exports = { | ||
DATE_TIME: 'datetime', | ||
TIME: 'time', | ||
BLOB: 'blob', | ||
@@ -10,0 +11,0 @@ TIMESTAMP: 'timestamp', |
@@ -240,3 +240,4 @@ var util = require('util'); | ||
runSql: function() { | ||
var callback = arguments[arguments.length - 1]; | ||
var args = this._makeParamArgs(arguments); | ||
var callback = args[2]; | ||
log.sql.apply(null, arguments); | ||
@@ -246,7 +247,16 @@ if(global.dryRun) { | ||
} | ||
return this.connection.query.apply(this.connection, arguments); | ||
return this.connection.query.apply(this.connection, args); | ||
}, | ||
_makeParamArgs: function(args) { | ||
var params = Array.prototype.slice.call(args); | ||
var sql = params.shift(); | ||
var callback = params.pop(); | ||
return [sql, params, callback]; | ||
}, | ||
all: function() { | ||
return this.connection.query.apply(this.connection, arguments); | ||
var args = this._makeParamArgs(arguments); | ||
return this.connection.query.apply(this.connection, args); | ||
}, | ||
@@ -253,0 +263,0 @@ |
@@ -27,3 +27,6 @@ var util = require('util'); | ||
var constraint = this.createColumnConstraint(spec, options); | ||
return ['"' + name + '"', type, len, constraint].join(' '); | ||
if (name.charAt(0) != '"') { | ||
name = '"' + name + '"'; | ||
} | ||
return [name, type, len, constraint].join(' '); | ||
}, | ||
@@ -30,0 +33,0 @@ |
@@ -15,2 +15,12 @@ var util = require('util'); | ||
mapDataType: function(str) { | ||
switch(str) { | ||
case type.DATE_TIME: | ||
return 'datetime'; | ||
case type.TIME: | ||
return 'time'; | ||
} | ||
return this._super(str); | ||
}, | ||
createColumnConstraint: function(spec, options) { | ||
@@ -17,0 +27,0 @@ var constraint = []; |
@@ -8,4 +8,12 @@ var fs = require('fs'); | ||
var filesRegEx = /\.js$/; | ||
var coffeeSupported = false; | ||
try { | ||
require('coffee-script'); | ||
coffeeSupported = true; | ||
filesRegEx = /\.(js|coffee)$/; | ||
} catch (e) {} | ||
function formatPath(dir, name) { | ||
return path.join(dir, name + '.js'); | ||
return path.join(dir, name); | ||
} | ||
@@ -103,3 +111,3 @@ | ||
Migration.parseName = function(path) { | ||
var match = path.match(/(\d{14}-[^.]+)\.js/); | ||
var match = path.match(/(\d{14}-[^.]+)(?:\.*?)?/); | ||
return match[1]; | ||
@@ -112,4 +120,9 @@ }; | ||
if (err) { callback(err); return; } | ||
var coffeeWarn = true; | ||
files = files.filter(function(file) { | ||
return /\.js$/.test(file); | ||
if (coffeeWarn && !coffeeSupported && /\.coffee$/.test(file)) { | ||
log.warn('CoffeeScript not installed'); | ||
coffeeWarn = false; | ||
} | ||
return filesRegEx.test(file); | ||
}); | ||
@@ -128,3 +141,3 @@ var migrations = files.sort().map(function(file) { | ||
var migrations = dbResults.map(function(result) { | ||
return new Migration(path.join(dir, result.name + '.js')); | ||
return new Migration(path.join(dir, result.name)); | ||
}); | ||
@@ -131,0 +144,0 @@ callback(null, migrations); |
{ | ||
"name": "db-migrate", | ||
"description": "Database migration framework for node.js", | ||
"author": "Jeff Kunkle <jeff.kunkle@nearinfinity.com>", | ||
"author": "Jeff Kunkle", | ||
"bin": "./bin/db-migrate", | ||
@@ -14,22 +14,8 @@ "keywords": [ | ||
], | ||
"version": "0.5.4", | ||
"version": "0.6.0", | ||
"engines": { | ||
"node": ">=0.6.0" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "Jeff Kunkle", | ||
"email": "jeff.kunkle@nearinfinity.com" | ||
}, | ||
{ | ||
"name": "Joe Ferner", | ||
"email": "joe.ferner@nearinfinity.com" | ||
}, | ||
{ | ||
"name": "Aaron Probus", | ||
"email": "aaron.probus@nearinfinity.com" | ||
} | ||
], | ||
"bugs": { | ||
"url": "https://github.com/nearinfinity/node-db-migrate/issues" | ||
"url": "https://github.com/kunklejr/node-db-migrate/issues" | ||
}, | ||
@@ -39,3 +25,3 @@ "license": "MIT", | ||
"type": "git", | ||
"url": "https://github.com/nearinfinity/node-db-migrate.git" | ||
"url": "https://github.com/kunklejr/node-db-migrate.git" | ||
}, | ||
@@ -42,0 +28,0 @@ "dependencies": { |
@@ -204,2 +204,15 @@ # db-migrate | ||
You can also specify environment variables in your config file by using a special notation. Here is an example: | ||
```javascript | ||
{ | ||
"prod": { | ||
"driver": "mysql", | ||
"user": {"ENV": "PRODUCTION_USERNAME"}, | ||
"password": {"ENV": "PRODUCTION_PASSWORD"} | ||
}, | ||
} | ||
``` | ||
In this case, db-migrate will search your environment for variables | ||
called `PRODUCTION_USERNAME` and `PRODUCTION_PASSWORD`, and use those values for the corresponding configuration entry. | ||
Note that if the settings for an environment are represented by a single string that string will be parsed as a database URL. | ||
@@ -206,0 +219,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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
100717
32
1659
439
8