pg-boss 10.0.3 → 10.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,6 +25,12 @@ async function readme() {
25
25
  console.log(`received job ${job.id} with data ${JSON.stringify(job.data)}`)
26
26
  })
27
27
  }
28
+
29
+ readme()
30
+ .catch(err => {
31
+ console.log(err)
32
+ process.exit(1)
33
+ })
28
34
  ```
29
35
 
30
36
  pg-boss is a job queue built in Node.js on top of PostgreSQL in order to provide background processing and reliable asynchronous execution to Node.js applications.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-boss",
3
- "version": "10.0.3",
3
+ "version": "10.0.4",
4
4
  "description": "Queueing jobs in Postgres from Node.js like a boss",
5
5
  "main": "./src/index.js",
6
6
  "engines": {
package/src/plans.js CHANGED
@@ -226,8 +226,10 @@ function createQueueFunction (schema) {
226
226
  $$
227
227
  DECLARE
228
228
  table_name varchar := 'j' || encode(sha224(queue_name::bytea), 'hex');
229
+ queue_created_on timestamptz;
229
230
  BEGIN
230
231
 
232
+ WITH q as (
231
233
  INSERT INTO ${schema}.queue (
232
234
  name,
233
235
  policy,
@@ -249,7 +251,15 @@ function createQueueFunction (schema) {
249
251
  (options->>'retentionMinutes')::int,
250
252
  options->>'deadLetter',
251
253
  table_name
252
- );
254
+ )
255
+ ON CONFLICT DO NOTHING
256
+ RETURNING created_on
257
+ )
258
+ SELECT created_on into queue_created_on from q;
259
+
260
+ IF queue_created_on IS NULL THEN
261
+ RETURN;
262
+ END IF;
253
263
 
254
264
  EXECUTE format('CREATE TABLE ${schema}.%I (LIKE ${schema}.job INCLUDING DEFAULTS)', table_name);
255
265