east-postgres
Advanced tools
Comparing version 0.1.1 to 1.0.0
'use strict'; | ||
var pg = require('pg.js'), | ||
var pg = require('pg'), | ||
path = require('path'), | ||
@@ -20,34 +20,11 @@ pgConnectionString = require('pg-connection-string'); | ||
var self = this; | ||
this.db = new pg.Client(this.params.url); | ||
this.db.connect(function(err) { | ||
if (err) { | ||
// if there is no target db and we have createDb option | ||
if (err.code === '3D000' && self.params.createDbOnConnect) { | ||
// then create db | ||
self._createDb(function(err) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
// and try to connect another time | ||
self.connect(callback); | ||
} | ||
}); | ||
} else { | ||
// just throw error | ||
callback(err); | ||
} | ||
this._connectAndCreateMigrationsTable(function(err) { | ||
if (err && err.code === '3D000' && self.params.createDbOnConnect) { | ||
self._createDb(function(err) { | ||
if (err) return callback(err); | ||
// and try to connect another time | ||
self._connectAndCreateMigrationsTable(callback); | ||
}); | ||
} else { | ||
// if connection is ok then try to create _migrations table | ||
self.db.query( | ||
'create table if not exists _migrations (' + | ||
'name text primary key' + | ||
')', | ||
function(err) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
callback(null, {db: self.db}); | ||
} | ||
} | ||
); | ||
callback.apply(null, arguments); | ||
} | ||
@@ -57,2 +34,15 @@ }); | ||
Adapter.prototype._connectAndCreateMigrationsTable = function(callback) { | ||
var self = this; | ||
this.db = new pg.Client(this.params.url); | ||
this.db.connect(function(err) { | ||
if (err) return callback(err); | ||
// create "migrations" table | ||
self._createMigrationsTable(function(err) { | ||
if (err) return callback(err); | ||
callback(null, {db: self.db}); | ||
}); | ||
}); | ||
}; | ||
Adapter.prototype.disconnect = function(callback) { | ||
@@ -107,2 +97,11 @@ this.db.end(); | ||
Adapter.prototype._createMigrationsTable = function(callback) { | ||
this.db.query( | ||
'create table if not exists _migrations (' + | ||
'name text primary key' + | ||
')', | ||
callback | ||
); | ||
}; | ||
module.exports = Adapter; |
{ | ||
"name": "east-postgres", | ||
"description": "postgres adapter for \"east\" (node.js database migration tool)", | ||
"version": "0.1.1", | ||
"version": "1.0.0", | ||
"author": "2do2go team <dev.2do2go@gmail.com>", | ||
@@ -15,5 +15,5 @@ "repository": { | ||
"dependencies": { | ||
"pg.js": ">=4.1.1", | ||
"pg": ">=4.1.1", | ||
"pg-connection-string": "0.1.3" | ||
} | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6014
1
98
+ Addedpg@>=4.1.1
+ Addedpg@8.12.0(transitive)
+ Addedpg-cloudflare@1.1.1(transitive)
+ Addedpg-connection-string@2.6.4(transitive)
+ Addedpg-int8@1.0.1(transitive)
+ Addedpg-pool@3.6.2(transitive)
+ Addedpg-protocol@1.6.1(transitive)
+ Addedpg-types@2.2.0(transitive)
+ Addedpgpass@1.0.5(transitive)
+ Addedpostgres-array@2.0.0(transitive)
+ Addedpostgres-bytea@1.0.0(transitive)
+ Addedpostgres-date@1.0.7(transitive)
+ Addedpostgres-interval@1.2.0(transitive)
+ Addedsplit2@4.2.0(transitive)
+ Addedxtend@4.0.2(transitive)
- Removedpg.js@>=4.1.1
- Removedbuffer-writer@1.0.0(transitive)
- Removedgeneric-pool@2.1.1(transitive)
- Removedpacket-reader@0.2.0(transitive)
- Removedpg-types@1.6.0(transitive)
- Removedpg.js@4.1.1(transitive)
- Removedpgpass@0.0.3(transitive)
- Removedsplit@0.3.3(transitive)
- Removedthrough@2.3.8(transitive)