mirror of
https://github.com/element-hq/synapse
synced 2024-09-11 14:45:10 +00:00
Don't assume db conn is a Context Manager.
Twisted adbapi wrapped connections aren't context managers.
This commit is contained in:
parent
5eefd1f618
commit
16dd87d848
1 changed files with 5 additions and 1 deletions
|
@ -583,7 +583,7 @@ def prepare_database(db_conn):
|
|||
"""Prepares a database for usage. Will either create all necessary tables
|
||||
or upgrade from an older schema version.
|
||||
"""
|
||||
with db_conn:
|
||||
try:
|
||||
cur = db_conn.cursor()
|
||||
version_info = _get_or_create_schema_state(cur)
|
||||
|
||||
|
@ -596,6 +596,10 @@ def prepare_database(db_conn):
|
|||
cur.execute("PRAGMA user_version = %d" % (SCHEMA_VERSION,))
|
||||
|
||||
cur.close()
|
||||
db_conn.commit()
|
||||
except:
|
||||
db_conn.rollback()
|
||||
raise
|
||||
|
||||
|
||||
def _setup_new_database(cur):
|
||||
|
|
Loading…
Reference in a new issue