tgriesser/knex — pull request #513 by sebastianseilund (2014-10-01 23:39:58+00:00)
Title: Added knex.migrate.to and knex.migrate.before

Like described in https://github.com/tgriesser/knex/issues/506

Example usage in test:

```js
describe('1234_my_change migration', function() {
//First set the db in the state before the migration we're testing
before(function() {
return db.migrate.before('1234_my_change.js')
})

describe('up', function() {
//Trigger `up` to be run
before(function() {
return db.migrate.to('1234_my_change.js')
})

it('created my_table', function() {
return knex.schema.hasTable('my_table')
.then(function(exists) {
assert(exists)
})
})
})

describe('down', function() {
//Trigger `down` to be run
before(function() {
return db.migrate.before('1234_my_change.js')
})

it('dropped my_table', function() {
return knex.schema.hasTable('my_table')
.then(function(exists) {
assert(!exists)
})
})
})
})
```

I also cleaned up the migration integration tests a bit. Isolated the tests for each method more and made sure that they each clean up after themselves.

Questions:

1. Should the name of the version be the complete filename? E.g. do you say `knex.migrate.to('12345678_my_thing.js')` or `knex.migrate.to('12345678')`? I prefer the first one, as there is no checks AFAICS whether the integer part is unique.

Let me know if there is anything you want me to look at.