KamoCRM

Recognise an existing CHECK constraint through Spring's wrapper

FixInitializerService
Shipped
11 ஆகஸ்ட், 2026 அன்று 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?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing