-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathup-migrations.js
35 lines (30 loc) · 987 Bytes
/
up-migrations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict'
const Migration = require('./migration')
module.exports = function upMigrations (set, migrationTitle) {
const titleIndex = set.indexOf(migrationTitle)
if (migrationTitle && titleIndex === -1) {
// @TODO wat to do?
// throw new Error(`Could not find migration: ${migrationTitle}`)
}
const toIndex = titleIndex !== -1 ? titleIndex : set.length
const fromIndex = set.indexOf(set.lastRun) + 1
return set.filter(function (migration, index) {
if (index > toIndex) {
return false
}
if (index < fromIndex) {
// @TODO wat to do? maybe nothing here
if (migration.state !== Migration.STATES.RAN_UP) {
// set.emit('warning', 'migrations running out of order')
return true
}
return false
}
// @TODO wat to do? maybe nothing here
if (migration.state === Migration.STATES.RAN_UP) {
// set.emit('warning', 'migrations running out of order')
return false
}
return true
})
}