1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-22 16:56:16 +00:00

Added a DatabaseUpdate that will stop if there are old messages without json in the database.

This commit is contained in:
Fabian Schlenz 2017-02-23 06:56:12 +01:00
parent f5d8b0c2e1
commit 2a82c5b374

View File

@ -35,6 +35,7 @@ public class DatabaseUpdates {
register(new DB_Update_6(conn, db));
register(new DB_Update_7(conn, db));
register(new DB_Update_8(conn, db));
register(new DB_Update_9(conn, db));
}
public void doUpdates() {
@ -330,3 +331,26 @@ class DB_Update_8 extends DatabaseUpdate {
conn.setAutoCommit(true);
}
}
class DB_Update_9 extends DatabaseUpdate {
public int getVersion() { return 9; }
public DB_Update_9(Connection conn, Database db) { super(conn, db); }
protected void _doUpdate() throws SQLException {
ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM messages WHERE api_layer=51 AND json IS NULL");
rs.next();
if (rs.getInt(1)>0) {
System.out.println();
System.out.println("There are some old messages in your DB that cannot be automatically converted.");
System.out.println("Sorry for that. We made some changes to prevent this from happening, but");
System.out.println("your old messages have to be converted to continue. Don't worry, nothing bad will");
System.out.println("happen and your backup is safe.");
System.out.println("But still the messages will have to be converted in order to continue running.");
System.out.println();
System.out.println("Please grab _URL_ and run it just like you would run this tool. It will convert");
System.out.println("those old messages. After that, you can run this tool again and it will continue.");
System.exit(1);
}
}
}