Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

anydb-sql-migrations

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anydb-sql-migrations - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

lib/index.js.map

11

d.ts/anydb-sql-migrations.d.ts

@@ -18,10 +18,9 @@ declare module "anydb-sql-migrations" {

}
export function create(db: AnydbSql, tasks: any): {
export function create(db: AnydbSql, tasks: string | MigrationTask[]): {
run: () => Promise<any>;
migrateTo: (target?: string) => Promise<any>;
check: (f: (m: {
type: string;
items: MigrationTask[];
}) => any) => Promise<any>;
check: (f: (items: MigrationTask[]) => any) => Promise<any>;
migrate: () => Promise<any>;
undoLast: () => Promise<any>;
drop: () => Promise<any>;
};
}
"use strict";
var Promise = require('bluebird');
var _ = require('lodash');
var fs = require('fs');
var path = require('path');
exports.__esModule = true;
var Promise = require("bluebird");
var _ = require("lodash");
var fs = require("fs");
var path = require("path");
function create(db, tasks) {

@@ -41,3 +42,3 @@ var list = [];

function remove(tx, name) {
return migrations.where({ version: name }).delete().execWithin(tx);
return migrations.where({ version: name })["delete"]().execWithin(tx);
}

@@ -64,2 +65,15 @@ function runSingle(tx, type, m) {

}
function undoAll() {
return runMigration(function (tx) { return migrations.select()
.order(migrations.version.descending)
.allWithin(tx).then(function (migrations) {
if (!migrations.length) {
throw new Error("No migrations available to rollback");
}
return Promise.all(migrations.map(function (mig) {
var task = _.find(list, function (item) { return item.name == mig.version; });
return runSingle(tx, "down", task);
}));
}); });
}
function loadFromPath(location) {

@@ -103,3 +117,14 @@ fs.readdirSync(location)

}
console.error("Add a --check, --execute or --rollback argument");
else if (args.drop) {
return undoAll().done(function (_) { return process.exit(0); }, function (e) {
if (e.message == 'No migrations available to rollback') {
console.error(e.message);
}
else {
console.error(e.stack);
}
process.exit(1);
});
}
console.error("Add a --check, --execute, --drop or --rollback argument");
process.exit(1);

@@ -111,4 +136,5 @@ }

tasks.forEach(function (task) { return defineMigration(task.name, task); });
return { run: run, check: check, migrate: migrate };
return { run: run, check: check, migrate: migrate, undoLast: undoLast, drop: undoAll };
}
exports.create = create;
//# sourceMappingURL=index.js.map
{
"name": "anydb-sql-migrations",
"version": "2.0.0",
"version": "2.1.0",
"description": "Database migrations for anydb-sql",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -56,3 +56,7 @@ require('source-map-support').install()

},
down: function() {}
down: function(tx) {
return db.user.drop().execWithin(tx)
.then(_ => db.account.drop().execWithin(tx))
.then(_ => db.storage.drop().execWithin(tx))
}
};

@@ -80,5 +84,6 @@

}).then(function() {
db.account.alter().dropColumn(db.account.credentials);
return Promise.resolve()
});
}
},
down: () => {return Promise.resolve()}
};

@@ -113,4 +118,14 @@

});
});
}).then(function() {
return migc2.drop()
}).then(function() {
db.storage.where({id: 1}).get()
.then(_ => { throw new Error("Table should not exist") },
e => t.ok(e.message, 'Expecting error trying to access storage table: ' + e.message))
}).then(function() {
return migc2.drop()
.then(res => {console.log(res); throw new Error('Drop should not work on empty db')},
e => t.ok(e.message, 'Expecting error trying to run drop on empty db: ' + e.message))
})
});
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