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)