Skip to content

Commit

Permalink
fix migration schema drift for on_complete
Browse files Browse the repository at this point in the history
  • Loading branch information
timgit committed Jun 25, 2021
1 parent 0bd1ae9 commit b28d33d
Show file tree
Hide file tree
Showing 7 changed files with 618 additions and 509 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Changes

## 6.1.1

- Fixed drift in schema migration between new and upgraded instances since the 6.0.0 release. In this case, the onComplete default was still set to true for direct table integrations on new intances, but migrated to the correct default of false for upgraded instances.
## 6.1.0

- Existing schemas can now be used via the `schema` property in the constructor.
Expand Down
1,102 changes: 600 additions & 502 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "pg-boss",
"version": "6.1.0",
"version": "6.1.1",
"description": "Queueing jobs in Node.js using PostgreSQL like a boss",
"main": "./src/index.js",
"engines": {
Expand All @@ -17,7 +17,7 @@
"devDependencies": {
"coveralls": "^3.1.0",
"luxon": "^1.26.0",
"mocha": "^8.3.2",
"mocha": "^9.0.1",
"nyc": "^15.1.0",
"standard": "^16.0.3"
},
Expand Down
10 changes: 9 additions & 1 deletion src/migrationStore.js
Expand Up @@ -22,7 +22,7 @@ function rollback (schema, version, migrations) {

assert(result, `Version ${version} not found.`)

return flatten(schema, result.uninstall, result.previous)
return flatten(schema, result.uninstall || [], result.previous)
}

function next (schema, version, migrations) {
Expand Down Expand Up @@ -67,6 +67,14 @@ function getAll (schema, config) {
const keepUntil = config ? config.keepUntil : DEFAULT_RETENTION

return [
{
release: '6.1.1',
version: 18,
previous: 17,
install: [
`ALTER TABLE ${schema}.job ALTER COLUMN on_complete SET DEFAULT false`
]
},
{
release: '6.0.0',
version: 17,
Expand Down
2 changes: 1 addition & 1 deletion src/plans.js
Expand Up @@ -145,7 +145,7 @@ function createJobTable (schema) {
createdOn timestamp with time zone not null default now(),
completedOn timestamp with time zone,
keepUntil timestamp with time zone NOT NULL default now() + interval '14 days',
on_complete boolean not null default true,
on_complete boolean not null default false,
output jsonb
)
`
Expand Down
4 changes: 2 additions & 2 deletions test/scheduleTest.js
Expand Up @@ -111,7 +111,7 @@ describe('schedule', function () {
it('should publish job based on current minute in UTC', async function () {
const boss = this.test.boss = await helper.start(this.test.bossConfig)

const queue = 'schedule-current-min-utc'
const queue = this.test.bossConfig.schema

const now = new Date()

Expand All @@ -136,7 +136,7 @@ describe('schedule', function () {
it('should publish job based on current minute in a specified time zone', async function () {
const boss = this.test.boss = await helper.start(this.test.bossConfig)

const queue = 'schedule-current-min-timezone'
const queue = this.test.bossConfig.schema

const tz = 'America/Los_Angeles'

Expand Down
2 changes: 1 addition & 1 deletion version.json
@@ -1,3 +1,3 @@
{
"schema": 17
"schema": 18
}

0 comments on commit b28d33d

Please sign in to comment.