east-rethink
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -13,2 +13,6 @@ 'use strict'; | ||
} | ||
if (typeof this.params.database.migrationTable !== 'string') { | ||
this.params.database.migrationTable = 'migration'; | ||
} | ||
}; | ||
@@ -25,2 +29,3 @@ | ||
const settings = Hoek.clone(self.params.database.connection); | ||
const tableName = self.params.database.migrationTable; | ||
this.db = new Pensuer.Db(self.params.database.name, settings); | ||
@@ -34,3 +39,3 @@ this.db.table(self.params.tables); | ||
this.db.establish({ migration: { purge: false } }, (err) => { | ||
this.db.establish({ [tableName]: { purge: false } }, (err) => { | ||
@@ -56,4 +61,7 @@ if (err) { | ||
this.db.migration.query({}, (err, migrations) => { | ||
const self = this; | ||
const tableName = self.params.database.migrationTable; | ||
this.db[tableName].query({}, (err, migrations) => { | ||
if (err) { | ||
@@ -76,4 +84,7 @@ return callback(err); | ||
this.db.migration.insert({ name: name, created: Date.now() }, (err, id) => { | ||
const self = this; | ||
const tableName = self.params.database.migrationTable; | ||
this.db[tableName].insert({ name: name, created: Date.now() }, (err, id) => { | ||
if (err) { | ||
@@ -89,4 +100,7 @@ return callback(err); | ||
this.db.migration.remove({ name: name }, (err) => { | ||
const self = this; | ||
const tableName = self.params.database.migrationTable; | ||
this.db[tableName].remove({ name: name }, (err) => { | ||
if (err) { | ||
@@ -93,0 +107,0 @@ return callback(err); |
@@ -0,10 +1,13 @@ | ||
'use strict'; | ||
exports.migrate = function(client, done) { | ||
var db = client.db; | ||
exports.migrate = (client, done) => { | ||
const db = client.db; | ||
done(); | ||
}; | ||
exports.rollback = function(client, done) { | ||
var db = client.db; | ||
exports.rollback = (client, done) => { | ||
const db = client.db; | ||
done(); | ||
}; | ||
}; |
{ | ||
"name": "east-rethink", | ||
"description": "rethinkdb adapter for \"east\" (node.js database migration tool)", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -38,2 +38,3 @@ # east rethink | ||
"name": "mydatabase", | ||
"migrationTable": "mymigrationtable", | ||
"connection": { | ||
@@ -49,3 +50,3 @@ "host": "localhost", | ||
* `tables` is an array of the tables you wish to connect to in your database. | ||
* `database` is a json object with the following properties: `name` - database name, `connection` - a json object with `host` and `port` providing the host name and port number for your database respectively. | ||
* `database` is a json object with the following properties: `name` - database name, `migrationTable` - migration table name (optional - defaults to 'migration'), `connection` - a json object with `host` and `port` providing the host name and port number for your database respectively. | ||
@@ -52,0 +53,0 @@ now we can create some migrations |
6386
84
177