This commit is contained in:
Tour
2025-12-06 07:04:53 +01:00
parent 4ecb6625c8
commit a25c0bdf5d

View File

@@ -252,8 +252,40 @@ public class DatabaseService {
// Table might not exist yet, which is fine
log.debug("Could not check lots table schema: " + e.getMessage());
}
// Check images table for missing columns and migrate
try (var rs = stmt.executeQuery("PRAGMA table_info(images)")) {
var hasLabels = false;
var hasLocalPath = false;
var hasProcessedAt = false;
while (rs.next()) {
var colName = rs.getString("name");
switch (colName) {
case "labels" -> hasLabels = true;
case "local_path" -> hasLocalPath = true;
case "processed_at" -> hasProcessedAt = true;
}
}
if (!hasLabels) {
log.info("Migrating schema: Adding 'labels' column to images table");
stmt.execute("ALTER TABLE images ADD COLUMN labels TEXT");
}
if (!hasLocalPath) {
log.info("Migrating schema: Adding 'local_path' column to images table");
stmt.execute("ALTER TABLE images ADD COLUMN local_path TEXT");
}
if (!hasProcessedAt) {
log.info("Migrating schema: Adding 'processed_at' column to images table");
stmt.execute("ALTER TABLE images ADD COLUMN processed_at INTEGER");
}
} catch (SQLException e) {
// Table might not exist yet, which is fine
log.debug("Could not check images table schema: " + e.getMessage());
}
}
/**
* Inserts or updates an auction record (typically called by external scraper)
*/