From dd2f88cf9a7b4342a5b6c859dde7b8f294bc6d70 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Thu, 23 Feb 2017 07:00:59 +0100 Subject: [PATCH] Added a database version check to 51converter. --- .../java/de/fabianonline/telegram_backup/Database.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/fabianonline/telegram_backup/Database.java b/src/main/java/de/fabianonline/telegram_backup/Database.java index 961ea98..60d5a59 100644 --- a/src/main/java/de/fabianonline/telegram_backup/Database.java +++ b/src/main/java/de/fabianonline/telegram_backup/Database.java @@ -102,7 +102,14 @@ public class Database { public void jsonify() { try { - ResultSet rs = stmt.executeQuery("SELECT id, data FROM messages WHERE api_layer=51"); + ResultSet rs = stmt.executeQuery("SELECT max(version) FROM database_versions"); + rs.next(); + if (rs.getInt(1) != 8) { + System.out.println("This tool will only run on a database version 8. Found: " + rs.getInt(1)); + System.exit(1); + } + rs.close(); + rs = stmt.executeQuery("SELECT id, data FROM messages WHERE api_layer=51"); PreparedStatement ps = conn.prepareStatement("UPDATE messages SET json=? WHERE id=?"); Gson gson = Utils.getGson(); while(rs.next()) {