diff --git a/convert_db.py b/convert_db.py old mode 100644 new mode 100755 index b4f9c0a..bc4a69a --- a/convert_db.py +++ b/convert_db.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# Convert between the old database format and the new one. +# You probably won't need to run this script. + import json import sqlite3 @@ -52,6 +56,10 @@ bans = old_db.execute("SELECT * FROM BANS").fetchall() print("Converting", len(bans), "rows") for ban in bans: + if 'post' not in ban: + print("ERROR: The database either does not exist, or already exists in the new format. Exiting") + raise SystemExit(1) + post = json.loads(ban["post"]) post["action"] = ban["action"] # post['board'] = ban['board']