From 355ece3e474041e8e94dfd90467d1348a4c12def Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 23 Jun 2016 16:26:36 -0700 Subject: [PATCH] db: turn on foreign keys --- src/wormhole/server/database.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wormhole/server/database.py b/src/wormhole/server/database.py index 00bd508..c772af7 100644 --- a/src/wormhole/server/database.py +++ b/src/wormhole/server/database.py @@ -35,6 +35,10 @@ def get_db(dbfile, target_version=TARGET_VERSION, stderr=sys.stderr): except (EnvironmentError, sqlite3.OperationalError) as e: raise DBError("Unable to create/open db file %s: %s" % (dbfile, e)) db.row_factory = dict_factory + db.execute("PRAGMA foreign_keys = ON") + problems = db.execute("PRAGMA foreign_key_check").fetchall() + if problems: + raise DBError("failed foreign key check: %s" % (problems,)) if must_create: schema = get_schema(target_version)