New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dbeasy

Package Overview
Dependencies
Maintainers
3
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dbeasy - npm Package Compare versions

Comparing version 0.11.1 to 0.11.2

10

migrator/index.js

@@ -118,6 +118,12 @@ 'use strict';

migrator.addMigrations = addMigrations;
function addMigrations(migrations) {
_.each(migrations, addMigration);
}
migrator.addMigration = addMigration;
function addMigration(migration) {
var prevMigrationDate = new Date('1970-01-01');
var prevMigrationDate =
(_.last(candidateMigrations) || {date : new Date('1970-01-01')}).date;
var date = migration.date;

@@ -138,3 +144,2 @@

}
prevMigrationDate = date;

@@ -220,3 +225,2 @@ candidateMigrations.push(_.cloneDeep(migration));

// console.log("ARGS", allMigrations, hasPending, hasMissing);
return [allMigrations, hasPending, hasMissing];

@@ -223,0 +227,0 @@ });

{
"name": "dbeasy",
"version": "0.11.1",
"version": "0.11.2",
"description": "Promise-based wrapper for postgresql driver that makes easy what should be easy while protecting your foot.",

@@ -32,3 +32,3 @@ "main": "index.js",

"moment-timezone": "^0.5.4",
"pg": "4.5.0",
"pg": "4.5.1",
"pg-native": "1.10.0",

@@ -35,0 +35,0 @@ "sprintf-js": "^1.0.3",

@@ -10,6 +10,4 @@ "use strict";

expect = require('chai').expect,
assert = require('assert'),
util = require('./util'),
makeMigrator = require('../migrator'),
parse = require('../migrator/parse'),
layout = require('../layout');

@@ -22,40 +20,3 @@

var testSqlPath = __dirname + '/test_migration_sql/';
suite('Parsing', function() {
test('Empty file yields emtpy array', function() {
return parse(testSqlPath + '00_empty.sql')
.then(function(migrations) {
expect(migrations).to.have.length(0);
});
});
test('Blank migration parses', function() {
return parse(testSqlPath + '01_comment_only.sql')
.then(function(migrations) {
var migration = migrations[0];
expect(migration.date).to.eql(new Date('2014-11-10T20:00'));
expect(migration.description).to.equal('Description goes here');
});
});
test('File with single migration parses', function() {
return parse(testSqlPath + '02_single_statement.sql')
.then(function(migrations) {
var migration = migrations[0];
expect(migration.template).to.contain('SELECT 1 FROM emp;');
});
});
test('File with multiple migrations parses', function() {
return parse(testSqlPath + '04_multiple_migrations.sql')
.then(function(migrations) {
expect(migrations).to.have.length(2);
expect(migrations[0].description).to.equal('Description 1 goes here');
expect(migrations[1].description).to.equal('Description 2 goes here');
});
});
});
suite('Running', function() {

@@ -217,61 +178,19 @@ var client;

return migrator.runPending(SCHEMA)
.then(function() {
return migrator.runPending(SCHEMA);
})
.then(function() {
migrator.addMigrations([{
date: new Date('2014-11-11T01:24'),
description: 'create rooms',
sql: 'CREATE TABLE school.classroom();'
}], {schema: 'school'});
return migrator.runPending(SCHEMA);
});
.then(function() {
return migrator.runPending(SCHEMA);
})
.then(function() {
var migrator = makeMigrator(client);
migrator.addMigrations([{
date: new Date('2014-11-11T01:24'),
description: 'create rooms',
sql: 'CREATE TABLE school.classroom();'
}], {schema: 'school'});
return migrator.runPending(SCHEMA);
});
});
test('Catch error on empty migration file', function() {
return migrator.loadMigrations(
testSqlPath + '00_empty.sql',
{schema: 'school'})
.then(function() {
throw new Error('Expected exception');
}, function(err) {
expect(err.message).to.match(/00_empty.sql/);
});
});
test('Load and run migrations from file', function() {
return migrator.loadMigrations(
testSqlPath + '10_create_classroom_table.sql',
{schema: 'school'})
.then(function() {
return migrator.runPending(SCHEMA);
})
.then(function() {
return Promise.all([
client.query('SELECT * FROM school.classroom;'),
]);
})
.spread(function(classrooms) {
expect(classrooms).to.be.empty;
});
});
test('Load and run migration with template', function() {
migrator.templateVars['table'] = 'school.classroom';
return migrator.loadMigrations(testSqlPath + '11_create_table.sql.hbs')
.then(function() {
return migrator.runPending(SCHEMA);
})
.then(function() {
return client.query('SELECT * FROM school.classroom;');
})
.then(function(classrooms) {
expect(classrooms).to.be.empty;
});
});
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc