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

timgit / pg-boss / 10016541428

20 Jul 2024 01:41AM UTC coverage: 93.17% (-6.8%) from 100.0%
10016541428

Pull #425

github

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

451 of 532 branches covered (84.77%)

357 of 381 new or added lines in 10 files covered. (93.7%)

40 existing lines in 5 files now uncovered.

873 of 937 relevant lines covered (93.17%)

805.36 hits per line

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

13.79
/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) {
UNCOV
19
  migrations = migrations || getAll(schema)
×
20

UNCOV
21
  const result = migrations.find(i => i.version === version)
×
22

UNCOV
23
  assert(result, `Version ${version} not found.`)
×
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

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

UNCOV
49
  migrations = migrations || getAll(schema, config)
×
50

UNCOV
51
  const result = migrations
×
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

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

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

65
function getAll (schema) {
66
  return [
182✔
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