db-migrate-pg
Advanced tools
Comparing version 0.2.5 to 0.3.0
26
index.js
@@ -19,3 +19,2 @@ var util = require('util'); | ||
this.schema = schema || "public"; | ||
this.connection.connect(); | ||
}, | ||
@@ -166,11 +165,11 @@ | ||
return this.all('select version() as version') | ||
return this.all('show server_version') | ||
.then(function(result) { | ||
if (result && result && result.length > 0 && result[0].version) { | ||
var version = result[0].version; | ||
var match = version.match(/\d+\.\d+\.\d+/); | ||
if (match && match[0] && semver.gte(match[0], '9.1.0')) { | ||
options.ifNotExists = true; | ||
if (result && result && result.length > 0 && result[0].server_version) { | ||
var version = result[0].server_version; | ||
if(version.split('.').length !== 3){ | ||
version += '.0'; | ||
} | ||
options.ifNotExists = semver.gte(version, '9.1.0'); | ||
} | ||
@@ -405,4 +404,5 @@ | ||
var using = columnSpec.using !== undefined ? | ||
columnSpec.using : util.format('USING "%s"::%s', columnName, this.mapDataType(columnSpec.type)) | ||
var sql = util.format('ALTER TABLE "%s" ALTER COLUMN "%s" TYPE %s %s', tableName, columnName, this.mapDataType(columnSpec.type), using); | ||
columnSpec.using : util.format('USING "%s"::%s', columnName, this.mapDataType(columnSpec.type)); | ||
var len = columnSpec.length ? util.format('(%s)', columnSpec.length) : ''; | ||
var sql = util.format('ALTER TABLE "%s" ALTER COLUMN "%s" TYPE %s %s %s', tableName, columnName, this.mapDataType(columnSpec.type), len, using); | ||
return this.runSql(sql); | ||
@@ -522,6 +522,12 @@ } | ||
if (config.native) { pg = pg.native; } | ||
if(!config.database) { config.database = 'postgres'; } | ||
var db = config.db || new pg.Client(config); | ||
callback(null, new PgDriver(db, config.schema, intern)); | ||
db.connect(function(err) { | ||
if(err) { | ||
callback(err); | ||
} | ||
callback(null, new PgDriver(db, config.schema, intern)); | ||
}); | ||
}; | ||
exports.base = PgDriver; |
{ | ||
"name": "db-migrate-pg", | ||
"version": "0.2.5", | ||
"version": "0.3.0", | ||
"description": "A postgresql driver for db-migrate", | ||
@@ -35,3 +35,3 @@ "main": "index.js", | ||
"db-migrate-base": "^1.5.2", | ||
"pg": "^4.5.7", | ||
"pg": "^7.0.0", | ||
"semver": "^5.0.3" | ||
@@ -38,0 +38,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
23595
427
+ Addedbuffer-writer@2.0.0(transitive)
+ Addedpacket-reader@1.0.0(transitive)
+ Addedpg@7.18.2(transitive)
+ Addedpg-packet-stream@1.1.0(transitive)
+ Addedpg-pool@2.0.10(transitive)
+ Addedpg-types@2.2.0(transitive)
+ Addedpgpass@1.0.5(transitive)
+ Addedpostgres-array@2.0.0(transitive)
+ Addedsemver@4.3.2(transitive)
+ Addedsplit2@4.2.0(transitive)
- Removedbuffer-writer@1.0.1(transitive)
- Removedgeneric-pool@2.4.2(transitive)
- Removedjs-string-escape@1.0.1(transitive)
- Removedpacket-reader@0.2.0(transitive)
- Removedpg@4.5.7(transitive)
- Removedpg-types@1.13.0(transitive)
- Removedpgpass@0.0.3(transitive)
- Removedpostgres-array@1.0.3(transitive)
- Removedsemver@4.3.6(transitive)
- Removedsplit@0.3.3(transitive)
- Removedthrough@2.3.8(transitive)
Updatedpg@^7.0.0