• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

timgit / pg-boss / 10342391608

11 Aug 2024 08:02PM UTC coverage: 98.113% (-1.9%) from 100.0%
10342391608

Pull #425

github

web-flow
Merge 08c8d4b84 into f1c1636ca
Pull Request #425: v10

441 of 504 branches covered (87.5%)

409 of 410 new or added lines in 10 files covered. (99.76%)

16 existing lines in 3 files now uncovered.

884 of 901 relevant lines covered (98.11%)

268.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

51.72
/src/migrationStore.js
1
const assert = require('assert')
4✔
2
const plans = require('./plans')
4✔
3

4
module.exports = {
4✔
5
  rollback,
6
  next,
7
  migrate,
8
  getAll
9
}
10

11
function flatten (schema, commands, version) {
UNCOV
12
  commands.unshift(plans.assertMigration(schema, version))
×
UNCOV
13
  commands.push(plans.setVersion(schema, version))
×
14

UNCOV
15
  return plans.locked(schema, commands)
×
16
}
17

18
function rollback (schema, version, migrations) {
19
  migrations = migrations || getAll(schema)
1✔
20

21
  const result = migrations.find(i => i.version === version)
1✔
22

23
  assert(result, `Version ${version} not found.`)
1✔
24

UNCOV
25
  return flatten(schema, result.uninstall || [], result.previous)
×
26
}
27

28
function next (schema, version, migrations) {
UNCOV
29
  migrations = migrations || getAll(schema)
×
30

UNCOV
31
  const result = migrations.find(i => i.previous === version)
×
32

UNCOV
33
  assert(result, `Version ${version} not found.`)
×
34

UNCOV
35
  return flatten(schema, result.install, result.version)
×
36
}
37

38
function migrate (value, version, migrations) {
39
  let schema, config
40

41
  if (typeof value === 'string') {
2✔
42
    config = null
1✔
43
    schema = value
1✔
44
  } else {
45
    config = value
1✔
46
    schema = config.schema
1✔
47
  }
48

49
  migrations = migrations || getAll(schema, config)
2✔
50

51
  const result = migrations
2✔
UNCOV
52
    .filter(i => i.previous >= version)
×
UNCOV
53
    .sort((a, b) => a.version - b.version)
×
54
    .reduce((acc, i) => {
UNCOV
55
      acc.install = acc.install.concat(i.install)
×
UNCOV
56
      acc.version = i.version
×
UNCOV
57
      return acc
×
58
    }, { install: [], version })
59

60
  assert(result.install.length > 0, `Version ${version} not found.`)
2✔
61

UNCOV
62
  return flatten(schema, result.install, result.version)
×
63
}
64

65
function getAll (schema) {
66
  return [
193✔
67
  ]
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc