Don't turn on sqlite refcheck stuff during migrations
authorChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 26 Apr 2013 20:09:03 +0000 (15:09 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Fri, 26 Apr 2013 20:09:03 +0000 (15:09 -0500)
mediagoblin/db/open.py
mediagoblin/gmg_commands/dbupdate.py

index 5fd5ed03234adfabed8e4342b2cde2a09098efa2..4c0694cc27a1bfcbaa60faf69093506f1719588c 100644 (file)
@@ -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)
index 65b3f922feaa454258ce5abb0ecda6f2891c8bde..f33d83d5002a19dd8151c8e4e4d307982dcf51dd 100644 (file)
@@ -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)