From 3c432c51f0e0d14175059461b2f819ab87fbe3b9 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 1 Jul 2020 16:00:09 -0700 Subject: [PATCH] Add database user_version check to merge_db. --- utilities/merge_db.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utilities/merge_db.py b/utilities/merge_db.py index 6a1b6b9..0830e00 100644 --- a/utilities/merge_db.py +++ b/utilities/merge_db.py @@ -25,6 +25,12 @@ def merge_db(from_db_path, to_db_path, channel): to_db = sqlite3.connect(to_db_path) from_db = sqlite3.connect(from_db_path) + to_version = to_db.execute('PRAGMA user_version').fetchone()[0] + from_version = from_db.execute('PRAGMA user_version').fetchone()[0] + + if to_version != from_version: + raise Exception(f'Databases have different versions: to={to_version}, from={from_version}.') + to_db.execute('ATTACH DATABASE "%s" AS other' % from_db_path) if channel == '*': _migrate_helper(to_db, 'channels')