graphile-worker
Advanced tools
Comparing version 0.16.0-rc.0 to 0.16.0-rc.1
@@ -156,2 +156,8 @@ import { Logger } from "@graphile/logger"; | ||
/** | ||
* Called if an error occurs during migration. | ||
*/ | ||
migrationError(event: GraphileWorker.MigrateEvent & { | ||
error: Error; | ||
}): PromiseOrDirect<void>; | ||
/** | ||
* Used to build a given `taskIdentifier`'s handler given a list of files, | ||
@@ -158,0 +164,0 @@ * if possible. |
import { PoolClient } from "pg"; | ||
import { migrations } from "./generated/sql"; | ||
import { WorkerSharedOptions } from "./interfaces"; | ||
import { CompiledSharedOptions } from "./lib"; | ||
/** @internal */ | ||
export declare function installSchema(compiledSharedOptions: CompiledSharedOptions<WorkerSharedOptions>, event: GraphileWorker.MigrateEvent): Promise<void>; | ||
/** @internal */ | ||
export declare function runMigration(compiledSharedOptions: CompiledSharedOptions<WorkerSharedOptions>, event: GraphileWorker.MigrateEvent, migrationFile: keyof typeof migrations, migrationNumber: number): Promise<void>; | ||
/** @internal */ | ||
export declare function migrate(compiledSharedOptions: CompiledSharedOptions<WorkerSharedOptions>, client: PoolClient): Promise<void>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.migrate = void 0; | ||
exports.migrate = exports.runMigration = exports.installSchema = void 0; | ||
const sql_1 = require("./generated/sql"); | ||
@@ -17,2 +17,3 @@ const lib_1 = require("./lib"); | ||
} | ||
/** @internal */ | ||
async function installSchema(compiledSharedOptions, event) { | ||
@@ -34,4 +35,6 @@ const { hooks, escapedWorkerSchema } = compiledSharedOptions; | ||
} | ||
exports.installSchema = installSchema; | ||
/** @internal */ | ||
async function runMigration(compiledSharedOptions, event, migrationFile, migrationNumber) { | ||
const { escapedWorkerSchema, logger } = compiledSharedOptions; | ||
const { escapedWorkerSchema, logger, hooks } = compiledSharedOptions; | ||
const rawText = sql_1.migrations[migrationFile]; | ||
@@ -59,5 +62,6 @@ const text = rawText.replace(/:GRAPHILE_WORKER_SCHEMA\b/g, escapedWorkerSchema); | ||
} | ||
catch (e) { | ||
catch (error) { | ||
await event.client.query("rollback"); | ||
if (!migrationInsertComplete && e.code === "23505") { | ||
await hooks.process("migrationError", { ...event, error }); | ||
if (!migrationInsertComplete && error.code === "23505") { | ||
// Someone else did this migration! Success! | ||
@@ -67,5 +71,9 @@ logger.debug(`Some other worker has performed migration ${migrationFile}; continuing.`); | ||
} | ||
throw e; | ||
if (error.code === "22012" && migrationNumber === 11) { | ||
throw new Error(`There are locked jobs present; migration 11 cannot complete. Please ensure all workers are shut down cleanly and all locked jobs and queues are unlocked before attempting this migration. To achieve this with minimal downtime, please consider using Worker Pro: https://worker.graphile.org/docs/pro/migration`); | ||
} | ||
throw error; | ||
} | ||
} | ||
exports.runMigration = runMigration; | ||
/** @internal */ | ||
@@ -72,0 +80,0 @@ async function migrate(compiledSharedOptions, client) { |
@@ -1,1 +0,1 @@ | ||
export declare const version = "0.16.0-rc.0"; | ||
export declare const version = "0.16.0-rc.1"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// This file is autogenerated by /scripts/postversion.mjs | ||
exports.version = "0.16.0-rc.0"; | ||
exports.version = "0.16.0-rc.1"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "graphile-worker", | ||
"version": "0.16.0-rc.0", | ||
"version": "0.16.0-rc.1", | ||
"type": "commonjs", | ||
@@ -19,3 +19,3 @@ "description": "Job queue for PostgreSQL", | ||
"preversion": "grep '^### Pending' RELEASE_NOTES.md && echo \"⚠️ Cannot publish with 'Pending' in RELEASE_NOTES ⚠️\" && exit 1 || true", | ||
"postversion": "node scripts/postversion.mjs", | ||
"version": "node scripts/postversion.mjs && git add src/version.ts", | ||
"website": "cd website && yarn run" | ||
@@ -22,0 +22,0 @@ }, |
@@ -0,1 +1,3 @@ | ||
<img width="120" height="120" title="Graphile Worker logo" src="https://cdn.rawgit.com/graphile/worker/2c8091e0bcce5d39e46a1b3833daf20b59097d1e/website/static/img/logo.optimized.svg" /> | ||
# graphile-worker | ||
@@ -2,0 +4,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
476206
7337
47