From 313b38f895332a700984adf8156ec9b3c4150b09 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Fri, 26 Apr 2013 15:09:03 -0500 Subject: [PATCH] Don't turn on sqlite refcheck stuff during migrations --- mediagoblin/db/open.py | 4 ++-- mediagoblin/gmg_commands/dbupdate.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mediagoblin/db/open.py b/mediagoblin/db/open.py index 5fd5ed03..4c0694cc 100644 --- a/mediagoblin/db/open.py +++ b/mediagoblin/db/open.py @@ -71,11 +71,11 @@ def _sqlite_fk_pragma_on_connect(dbapi_con, con_record): dbapi_con.execute('pragma foreign_keys=on') -def setup_connection_and_db_from_config(app_config): +def setup_connection_and_db_from_config(app_config, sqlite_refcheck=True): engine = create_engine(app_config['sql_engine']) # Enable foreign key checking for sqlite - if app_config['sql_engine'].startswith('sqlite://'): + if app_config['sql_engine'].startswith('sqlite://') and sqlite_refcheck: event.listen(engine, 'connect', _sqlite_fk_pragma_on_connect) # logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) diff --git a/mediagoblin/gmg_commands/dbupdate.py b/mediagoblin/gmg_commands/dbupdate.py index 65b3f922..f33d83d5 100644 --- a/mediagoblin/gmg_commands/dbupdate.py +++ b/mediagoblin/gmg_commands/dbupdate.py @@ -114,7 +114,7 @@ def run_dbupdate(app_config, global_config): global_config.get('plugins', {}).keys()) # Set up the database - db = setup_connection_and_db_from_config(app_config) + db = setup_connection_and_db_from_config(app_config, sqlite_refcheck=False) Session = sessionmaker(bind=db.engine) -- 2.25.1