Recognise an existing CHECK constraint through Spring's wrapper

FixInitializerService
Shipped
August 11, 2026 at 11:56 PM UTC
Author
Kamo
Commit
ae42fab

TrainingSchemaMigration @Order(43) has been aborting EVERY KamoInitializer run, silently withholding all 29 runners ordered after it (orders 45-112). Observed in production 2026-08-11. ITEM_TARGET_CHECK_SQL's javadoc promises the duplicate-constraint error is 'caught and treated as success below', and ensureCheckConstraint does try to -- but it tested e.getMessage() only. Spring wraps the driver's PSQLException in a BadSqlGrammarException whose own message is ONLY the offending SQL; the 'constraint ... already exists' text is on the cause. So the check never matched and the runner threw. Fixed by walking the cause chain, exactly as the neighbouring isRetryable already does. Regression test pins the wrapped shape specifically, since the unwrapped one always passed and is what hid this.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing