summary refs log tree commit diff
path: root/scripts-dev
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-12-12 10:37:56 +0000
committerGitHub <noreply@github.com>2019-12-12 10:37:56 +0000
commitb8e4b39b69562cc0377ada84682752c1ad5e949d (patch)
tree009e2b01d37ddd86883f5ac04608d836217303c0 /scripts-dev
parentAdd `include_event_in_state` to _get_state_for_room (#6521) (diff)
parentAdd new config param to docstring and add types (diff)
downloadsynapse-b8e4b39b69562cc0377ada84682752c1ad5e949d.tar.xz
Merge pull request #6511 from matrix-org/erikj/remove_db_config_from_apps
Move database config from apps into HomeServer object
Diffstat (limited to 'scripts-dev')
-rwxr-xr-xscripts-dev/update_database33
1 files changed, 6 insertions, 27 deletions
diff --git a/scripts-dev/update_database b/scripts-dev/update_database
index 1776d202c5..23017c21f8 100755
--- a/scripts-dev/update_database
+++ b/scripts-dev/update_database
@@ -26,7 +26,6 @@ from synapse.config.homeserver import HomeServerConfig
 from synapse.metrics.background_process_metrics import run_as_background_process
 from synapse.server import HomeServer
 from synapse.storage import DataStore
-from synapse.storage.engines import create_engine
 from synapse.storage.prepare_database import prepare_database
 
 logger = logging.getLogger("update_database")
@@ -35,21 +34,11 @@ logger = logging.getLogger("update_database")
 class MockHomeserver(HomeServer):
     DATASTORE_CLASS = DataStore
 
-    def __init__(self, config, database_engine, db_conn, **kwargs):
+    def __init__(self, config, **kwargs):
         super(MockHomeserver, self).__init__(
-            config.server_name,
-            reactor=reactor,
-            config=config,
-            database_engine=database_engine,
-            **kwargs
+            config.server_name, reactor=reactor, config=config, **kwargs
         )
 
-        self.database_engine = database_engine
-        self.db_conn = db_conn
-
-    def get_db_conn(self):
-        return self.db_conn
-
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(
@@ -85,24 +74,14 @@ if __name__ == "__main__":
     config = HomeServerConfig()
     config.parse_config_dict(hs_config, "", "")
 
-    # Create the database engine and a connection to it.
-    database_engine = create_engine(config.database_config)
-    db_conn = database_engine.module.connect(
-        **{
-            k: v
-            for k, v in config.database_config.get("args", {}).items()
-            if not k.startswith("cp_")
-        }
-    )
+    # Instantiate and initialise the homeserver object.
+    hs = MockHomeserver(config)
 
+    db_conn = hs.get_db_conn()
     # Update the database to the latest schema.
-    prepare_database(db_conn, database_engine, config=config)
+    prepare_database(db_conn, hs.database_engine, config=config)
     db_conn.commit()
 
-    # Instantiate and initialise the homeserver object.
-    hs = MockHomeserver(
-        config, database_engine, db_conn, db_config=config.database_config,
-    )
     # setup instantiates the store within the homeserver object.
     hs.setup()
     store = hs.get_datastore()