fix: sort ClickHouse migration scripts by numeric version prefix
All checks were successful
CI / build (push) Successful in 2m32s
CI / cleanup-branch (push) Has been skipped
CI / docker (push) Successful in 55s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 52s

Alphabetical sort put V10/V11 before V2-V9 ("V11" < "V1_" in ASCII),
causing the route_diagrams projection to run before the table existed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-03 15:06:56 +02:00
parent 6f00ff2e28
commit 984bb2d40f

View File

@@ -35,7 +35,17 @@ public class ClickHouseSchemaInitializer {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] scripts = resolver.getResources("classpath:clickhouse/*.sql");
Arrays.sort(scripts, Comparator.comparing(Resource::getFilename));
// Sort by numeric version prefix (V1, V2, ..., V10, V11) — not alphabetically
Arrays.sort(scripts, Comparator.comparingInt(r -> {
String name = r.getFilename();
if (name != null && name.startsWith("V")) {
int end = name.indexOf('_');
if (end > 1) {
try { return Integer.parseInt(name.substring(1, end)); } catch (NumberFormatException ignored) {}
}
}
return Integer.MAX_VALUE;
}));
for (Resource script : scripts) {
String sql = script.getContentAsString(StandardCharsets.UTF_8);