Skip to content

Commit 492cd14

Browse files
cardmagicclaude
andcommitted
fix: look for the column in this database only
`information_schema.columns` spans every schema on PostgreSQL and every database on MySQL, so a same-named table elsewhere could answer for this one. The column check would then skip the `ALTER`, record migration 11, and leave every later query referencing a column that is not there. The lookup narrows to `current_schema()` or `DATABASE()`, as the other metadata queries in this repository already do. `RedriveManager.start` and the filter parameters take the types the rest of the code uses, rather than restating `unknown`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent a51fc19 commit 492cd14

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/dead-letter-scopes.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { AdministrationOptions, DeepReadonly, JsonObject } from "./types.js
66

77
export type DeadLetterKind = "effect" | "broadcast"
88

9+
type DeadRowFilterValue = string | number
10+
911
export interface DeadRow {
1012
readonly id: string
1113
readonly kind: DeadLetterKind
@@ -157,9 +159,9 @@ export class DeadLetterScope {
157159
private conditions(
158160
filters: RedriveFilters,
159161
deadBefore?: number,
160-
): { where: string; parameters: unknown[] } {
162+
): { where: string; parameters: DeadRowFilterValue[] } {
161163
const clauses = ["dead.status = 'dead'"]
162-
const parameters: unknown[] = []
164+
const parameters: DeadRowFilterValue[] = []
163165
if (deadBefore !== undefined) {
164166
clauses.push("dead.failed_at_ms <= ?")
165167
parameters.push(deadBefore)

‎src/redrive.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class RedriveManager {
3838
async start(input: {
3939
kind: DeadLetterKind
4040
filters: RedriveFilters
41-
authorizationContext?: unknown
41+
authorizationContext?: AdministrationOptions["authorizationContext"]
4242
}): Promise<RedriveTask> {
4343
await this.runtime.deadLetters.scope(input.kind).authorize({
4444
action: "redrive",

‎src/schema.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,10 @@ async function hasFailedAt(options: {
461461
)
462462
return columns.some(({ name }) => name === "failed_at_ms")
463463
}
464+
const schema = options.family === "postgresql" ? "current_schema()" : "DATABASE()"
464465
const found = await options.connection.get<{ found: number | bigint }>(
465466
`SELECT COUNT(*) AS found FROM information_schema.columns
466-
WHERE table_name = ? AND column_name = 'failed_at_ms'`,
467+
WHERE table_schema = ${schema} AND table_name = ? AND column_name = 'failed_at_ms'`,
467468
[options.table],
468469
)
469470
return Number(found?.found ?? 0) > 0

0 commit comments

Comments
 (0)