Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
2e447142
Commit
2e447142
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Make failure to run appropraite upgrade scripts more helpful.
parent
592ba14b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/app/homeserver.py
+10
-3
10 additions, 3 deletions
synapse/app/homeserver.py
synapse/storage/__init__.py
+12
-0
12 additions, 0 deletions
synapse/storage/__init__.py
with
22 additions
and
3 deletions
synapse/app/homeserver.py
+
10
−
3
View file @
2e447142
...
...
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
synapse.storage
import
prepare_database
from
synapse.storage
import
prepare_database
,
UpgradeDatabaseException
from
synapse.server
import
HomeServer
...
...
@@ -228,8 +228,15 @@ def setup():
logger
.
info
(
"
Preparing database: %s...
"
,
db_name
)
with
sqlite3
.
connect
(
db_name
)
as
db_conn
:
prepare_database
(
db_conn
)
try
:
with
sqlite3
.
connect
(
db_name
)
as
db_conn
:
prepare_database
(
db_conn
)
except
UpgradeDatabaseException
:
sys
.
stderr
.
write
(
"
\n
Failed to upgrade database.
\n
"
"
Have you followed any instructions in UPGRADES.rst?
\n
"
)
sys
.
exit
(
1
)
logger
.
info
(
"
Database prepared in %s.
"
,
db_name
)
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/__init__.py
+
12
−
0
View file @
2e447142
...
...
@@ -526,6 +526,14 @@ def read_schema(schema):
return
schema_file
.
read
()
class
PrepareDatabaseException
(
Exception
):
pass
class
UpgradeDatabaseException
(
PrepareDatabaseException
):
pass
def
prepare_database
(
db_conn
):
"""
Set up all the dbs. Since all the *.sql have IF NOT EXISTS, so we
don
'
t have to worry about overwriting existing content.
...
...
@@ -542,6 +550,10 @@ def prepare_database(db_conn):
"
Cannot use this database as it is too
"
+
"
new for the server to understand
"
)
elif
user_version
<
10
:
raise
UpgradeDatabaseException
(
"
No delta for versions less than 10
"
)
elif
user_version
<
SCHEMA_VERSION
:
logger
.
info
(
"
Upgrading database from version %d
"
,
...
...
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