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:
@@ -21,14 +21,14 @@ public class PostgresAppVersionRepository implements AppVersionRepository {
|
|||||||
@Override
|
@Override
|
||||||
public List<AppVersion> findByAppId(UUID appId) {
|
public List<AppVersion> findByAppId(UUID appId) {
|
||||||
return jdbc.query(
|
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);
|
(rs, rowNum) -> mapRow(rs), appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<AppVersion> findById(UUID id) {
|
public Optional<AppVersion> findById(UUID id) {
|
||||||
var results = jdbc.query(
|
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);
|
(rs, rowNum) -> mapRow(rs), id);
|
||||||
return results.isEmpty() ? Optional.empty() : Optional.of(results.get(0));
|
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);
|
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 {
|
private AppVersion mapRow(ResultSet rs) throws SQLException {
|
||||||
Long sizeBytes = rs.getLong("jar_size_bytes");
|
Long sizeBytes = rs.getLong("jar_size_bytes");
|
||||||
if (rs.wasNull()) sizeBytes = null;
|
if (rs.wasNull()) sizeBytes = null;
|
||||||
@@ -65,6 +71,8 @@ public class PostgresAppVersionRepository implements AppVersionRepository {
|
|||||||
rs.getString("jar_checksum"),
|
rs.getString("jar_checksum"),
|
||||||
rs.getString("jar_filename"),
|
rs.getString("jar_filename"),
|
||||||
sizeBytes,
|
sizeBytes,
|
||||||
|
rs.getString("detected_runtime_type"),
|
||||||
|
rs.getString("detected_main_class"),
|
||||||
rs.getTimestamp("uploaded_at").toInstant()
|
rs.getTimestamp("uploaded_at").toInstant()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE app_versions ADD COLUMN detected_runtime_type VARCHAR;
|
||||||
|
ALTER TABLE app_versions ADD COLUMN detected_main_class VARCHAR;
|
||||||
@@ -4,4 +4,5 @@ import java.time.Instant;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public record AppVersion(UUID id, UUID appId, int version, String jarPath, String jarChecksum,
|
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) {}
|
||||||
|
|||||||
@@ -10,4 +10,5 @@ public interface AppVersionRepository {
|
|||||||
int findMaxVersion(UUID appId);
|
int findMaxVersion(UUID appId);
|
||||||
UUID create(UUID appId, int version, String jarPath, String jarChecksum, String jarFilename, Long jarSizeBytes);
|
UUID create(UUID appId, int version, String jarPath, String jarChecksum, String jarFilename, Long jarSizeBytes);
|
||||||
void delete(UUID id);
|
void delete(UUID id);
|
||||||
|
void updateDetectedRuntime(UUID id, String detectedRuntimeType, String detectedMainClass);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user