Socket
Socket
Sign inDemoInstall

db-migrate

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db-migrate - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

4

CHANGELOG.md

@@ -73,1 +73,5 @@ ## 0.1.0

## 0.2.5
Fix:
- Fix randomly occuring migration sorting error on empty db #51

2

lib/driver/base.js

@@ -161,3 +161,3 @@ var util = require('util');

if (typeof(valueArray[index]) === 'string') {
values += "'" + valueArray[index] + "'";
values += "'" + valueArray[index].replace("'", "''") + "'";
} else {

@@ -164,0 +164,0 @@ values += valueArray[index];

@@ -6,7 +6,12 @@ exports.connect = function(config, callback) {

var driver = require('./' + config.driver);
driver.connect(config, function(err, db) {
if (err) { callback(err); return; }
callback(null, db);
});
if (typeof(config.driver) === 'string') {
var driver = require('./' + config.driver);
driver.connect(config, function(err, driverInstance) {
if (err) { callback(err); return; }
callback(null, driverInstance);
});
} else {
// the user has already created the driver
callback(null, config.driver);
}
};

@@ -25,3 +25,7 @@ var async = require('async');

function filterUp(allMigrations, completedMigrations, destination, count) {
return allMigrations.sort()
var sortFn = function(a, b) {
return a.name.slice(0, a.name.indexOf('-')) - b.name.slice(0, b.name.indexOf('-'));
};
return allMigrations.sort(sortFn)
.filter(function(migration) {

@@ -28,0 +32,0 @@ var hasRun = completedMigrations.some(function(completedMigration) {

@@ -14,3 +14,3 @@ {

],
"version": "0.2.4",
"version": "0.2.5",
"engines": {

@@ -17,0 +17,0 @@ "node": ">=0.6.0"

@@ -170,3 +170,3 @@ # db-migrate

db-migrate supports the concept of environments. For example, you might have a dev, test, and prod environment where you need to run the migrations at different times. Environment settings are loaded from a database.json file like the one shown below:
db-migrate supports the concept of environments. For example, you might have a dev, test, and prod environment where you need to run the migrations at different times. By default, environment settings are loaded from a database.json file like the one shown below:

@@ -190,3 +190,3 @@ ```javascript

},
"pg": {

@@ -202,4 +202,40 @@ "driver": "pg",

You can pass the -e or --env option to db-migrate to select the environment you want to run migrations against. The --config option can be used to specify the path to your database.json file if it's not in the current working directory.
Your database configuration can also be specified using a JavaScript
file. This is helpful when you'd like to manually instantiate and
configure the database driver. Below is an example of what a
JavaScript-based configuration file would need to look like.
```javascript
var mysqlDriver = require('db-migrate/lib/driver/mysql');
var mysql = require('mysql');
var pgDriver = require('db-migrate/lib/driver/pg');
var pg = require('pg');
var sqlite3Driver = require('db-migrate/lib/driver/sqlite3');
var sqlite3 = require('sqlite3');
var sqlite3Mode = sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE;
module.exports = {
dev: {
driver: new sqlite3.Database('~/dev.db', mode);
},
test: {
driver: new sqlite3.Database(':memory:', mode);
},
prod: {
driver: new mysql.createClient({
"user": "root",
"password": "root"
})
},
pg: {
driver:
}
};
```
You can pass the -e or --env option to db-migrate to select the environment you want to run migrations against. The --config option can be used to specify the path to your database config file if it's not in the current working directory.
db-migrate up --config config/database.json -e prod

@@ -206,0 +242,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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