Socket
Socket
Sign inDemoInstall

east-postgres

Package Overview
Dependencies
35
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 1.0.0

63

lib/adapter.js
'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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc