Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
67c991b7
Commit
67c991b7
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix upgrade db script
parent
bc5cb8bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts-dev/update_database
+6
-27
6 additions, 27 deletions
scripts-dev/update_database
with
6 additions
and
27 deletions
scripts-dev/update_database
+
6
−
27
View file @
67c991b7
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment