good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
chat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
github
tinode
chat
Commits
6dde8936
Commit
6dde8936
authored
2 years ago
by
or-else
Browse files
Options
Downloads
Patches
Plain Diff
do not attempt to upgrade if db version is higher than expected
parent
8128d6d9
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
tinode-db/main.go
+8
-3
8 additions, 3 deletions
tinode-db/main.go
with
8 additions
and
3 deletions
tinode-db/main.go
+
8
−
3
View file @
6dde8936
...
...
@@ -240,7 +240,9 @@ func main() {
err
:=
store
.
Store
.
Open
(
1
,
config
.
StoreConfig
)
defer
store
.
Store
.
Close
()
log
.
Printf
(
"Database adapter: '%s'; version: %d"
,
store
.
Store
.
GetAdapterName
(),
store
.
Store
.
GetAdapterVersion
())
adapterVersion
:=
store
.
Store
.
GetAdapterVersion
()
databaseVersion
:=
store
.
Store
.
GetDbVersion
()
log
.
Printf
(
"Database adapter: '%s'; version: %d"
,
store
.
Store
.
GetAdapterName
(),
adapterVersion
)
if
err
!=
nil
{
if
strings
.
Contains
(
err
.
Error
(),
"Database not initialized"
)
{
...
...
@@ -249,11 +251,14 @@ func main() {
}
log
.
Println
(
"Database not found. Creating."
)
}
else
if
strings
.
Contains
(
err
.
Error
(),
"Invalid database version"
)
{
msg
:=
"Wrong DB version: expected "
+
strconv
.
Itoa
(
store
.
Store
.
GetA
dapterVersion
()
)
+
", got "
+
strconv
.
Itoa
(
store
.
Store
.
GetDb
Version
()
)
+
"."
msg
:=
"Wrong DB version: expected "
+
strconv
.
Itoa
(
a
dapterVersion
)
+
", got "
+
strconv
.
Itoa
(
database
Version
)
+
"."
if
*
reset
{
log
.
Println
(
msg
,
"Dropping and recreating the database."
)
}
else
if
*
upgrade
{
if
databaseVersion
>
adapterVersion
{
log
.
Fatalln
(
msg
,
"Unable to upgrade: database has greater version than the adapter."
)
}
log
.
Println
(
msg
,
"Upgrading the database."
)
}
else
{
log
.
Fatalln
(
msg
,
"Use --reset to reset, --upgrade to upgrade."
)
...
...
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