From: Christopher Allan Webber Date: Fri, 26 Apr 2013 20:09:03 +0000 (-0500) Subject: Don't turn on sqlite refcheck stuff during migrations X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=313b38f895332a700984adf8156ec9b3c4150b09;p=mediagoblin.git Don't turn on sqlite refcheck stuff during migrations --- 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)