* Walks the `cause` chain so a SQLSTATE code is found even when drizzle wraps the * driver error (the code commonly lives on the inner `cause`, not the outer throw).
(error: unknown)
| 25 | * driver error (the code commonly lives on the inner `cause`, not the outer throw). |
| 26 | */ |
| 27 | function isSchemaMismatch(error: unknown): boolean { |
| 28 | const seen = new Set<unknown>() |
| 29 | let current: unknown = error |
| 30 | while (current && typeof current === 'object' && !seen.has(current)) { |
| 31 | seen.add(current) |
| 32 | const code = (current as { code?: unknown }).code |
| 33 | if (typeof code === 'string' && SCHEMA_MISMATCH_CODES.has(code)) { |
| 34 | return true |
| 35 | } |
| 36 | current = (current as { cause?: unknown }).cause |
| 37 | } |
| 38 | return false |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Verifies, before the server accepts traffic, that the deployed image's schema |
no test coverage detected