feat: add detected_runtime_type and detected_main_class to app_versions

Flyway V10 migration adds the two nullable columns. AppVersion record,
AppVersionRepository interface, and PostgresAppVersionRepository are
updated to carry and persist detected runtime information.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-12 13:01:24 +02:00
parent cbf29a5d87
commit f4bbc1f65f
4 changed files with 15 additions and 3 deletions

View File

@@ -21,14 +21,14 @@ public class PostgresAppVersionRepository implements AppVersionRepository {
@Override
public List<AppVersion> findByAppId(UUID appId) {
return jdbc.query(
"SELECT id, app_id, version, jar_path, jar_checksum, jar_filename, jar_size_bytes, uploaded_at FROM app_versions WHERE app_id = ? ORDER BY version DESC",
"SELECT id, app_id, version, jar_path, jar_checksum, jar_filename, jar_size_bytes, detected_runtime_type, detected_main_class, uploaded_at FROM app_versions WHERE app_id = ? ORDER BY version DESC",
(rs, rowNum) -> mapRow(rs), appId);
}
@Override
public Optional<AppVersion> findById(UUID id) {
var results = jdbc.query(
"SELECT id, app_id, version, jar_path, jar_checksum, jar_filename, jar_size_bytes, uploaded_at FROM app_versions WHERE id = ?",
"SELECT id, app_id, version, jar_path, jar_checksum, jar_filename, jar_size_bytes, detected_runtime_type, detected_main_class, uploaded_at FROM app_versions WHERE id = ?",
(rs, rowNum) -> mapRow(rs), id);
return results.isEmpty() ? Optional.empty() : Optional.of(results.get(0));
}
@@ -54,6 +54,12 @@ public class PostgresAppVersionRepository implements AppVersionRepository {
jdbc.update("DELETE FROM app_versions WHERE id = ?", id);
}
@Override
public void updateDetectedRuntime(UUID id, String detectedRuntimeType, String detectedMainClass) {
jdbc.update("UPDATE app_versions SET detected_runtime_type = ?, detected_main_class = ? WHERE id = ?",
detectedRuntimeType, detectedMainClass, id);
}
private AppVersion mapRow(ResultSet rs) throws SQLException {
Long sizeBytes = rs.getLong("jar_size_bytes");
if (rs.wasNull()) sizeBytes = null;
@@ -65,6 +71,8 @@ public class PostgresAppVersionRepository implements AppVersionRepository {
rs.getString("jar_checksum"),
rs.getString("jar_filename"),
sizeBytes,
rs.getString("detected_runtime_type"),
rs.getString("detected_main_class"),
rs.getTimestamp("uploaded_at").toInstant()
);
}

View File

@@ -0,0 +1,2 @@
ALTER TABLE app_versions ADD COLUMN detected_runtime_type VARCHAR;
ALTER TABLE app_versions ADD COLUMN detected_main_class VARCHAR;

View File

@@ -4,4 +4,5 @@ import java.time.Instant;
import java.util.UUID;
public record AppVersion(UUID id, UUID appId, int version, String jarPath, String jarChecksum,
String jarFilename, Long jarSizeBytes, Instant uploadedAt) {}
String jarFilename, Long jarSizeBytes, String detectedRuntimeType,
String detectedMainClass, Instant uploadedAt) {}

View File

@@ -10,4 +10,5 @@ public interface AppVersionRepository {
int findMaxVersion(UUID appId);
UUID create(UUID appId, int version, String jarPath, String jarChecksum, String jarFilename, Long jarSizeBytes);
void delete(UUID id);
void updateDetectedRuntime(UUID id, String detectedRuntimeType, String detectedMainClass);
}