Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vincent Pelletier
neoppod
Commits
04f6d9c3
Commit
04f6d9c3
authored
Nov 28, 2017
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: update backend version between each migration step
parent
875fc1b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
neo/storage/database/manager.py
neo/storage/database/manager.py
+5
-2
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+6
-7
neo/storage/database/sqlite.py
neo/storage/database/sqlite.py
+6
-7
No files found.
neo/storage/database/manager.py
View file @
04f6d9c3
...
...
@@ -161,11 +161,14 @@ class DatabaseManager(object):
"The database can not be upgraded because you have unfinished"
" transactions. Use an older version of NEO to verify them."
)
def
_getVersion
(
self
):
def
migrate
(
self
):
version
=
int
(
self
.
getConfiguration
(
"version"
)
or
0
)
if
self
.
VERSION
<
version
:
raise
DatabaseFailure
(
"The database can not be downgraded."
)
return
version
while
version
<
self
.
VERSION
:
version
+=
1
getattr
(
self
,
'_migrate%s'
%
version
)()
self
.
setConfiguration
(
"version"
,
version
)
def
doOperation
(
self
,
app
):
pass
...
...
neo/storage/database/mysqldb.py
View file @
04f6d9c3
...
...
@@ -176,6 +176,10 @@ class MySQLDatabaseManager(DatabaseManager):
if
e
.
args
[
0
]
!=
NO_SUCH_TABLE
:
raise
def
_migrate1
(
self
):
self
.
_checkNoUnfinishedTransactions
()
self
.
query
(
"DROP TABLE IF EXISTS ttrans"
)
def
_setup
(
self
,
dedup
=
False
):
self
.
_config
.
clear
()
q
=
self
.
query
...
...
@@ -188,14 +192,9 @@ class MySQLDatabaseManager(DatabaseManager):
name VARBINARY(255) NOT NULL PRIMARY KEY,
value VARBINARY(255) NULL
) ENGINE="""
+
engine
)
self
.
_setConfiguration
(
"version"
,
self
.
VERSION
)
else
:
# Automatic migration.
version
=
self
.
_getVersion
()
if
version
<
1
:
self
.
_checkNoUnfinishedTransactions
()
q
(
"DROP TABLE IF EXISTS ttrans"
)
self
.
_setConfiguration
(
"version"
,
self
.
VERSION
)
self
.
migrate
()
# The table "pt" stores a partition table.
q
(
"""CREATE TABLE IF NOT EXISTS pt (
...
...
neo/storage/database/sqlite.py
View file @
04f6d9c3
...
...
@@ -112,6 +112,10 @@ class SQLiteDatabaseManager(DatabaseManager):
if
not
e
.
args
[
0
].
startswith
(
"no such table:"
):
raise
def
_migrate1
(
self
):
self
.
_checkNoUnfinishedTransactions
()
self
.
query
(
"DROP TABLE IF EXISTS ttrans"
)
def
_setup
(
self
,
dedup
=
False
):
# SQLite does support transactional Data Definition Language statements
# but unfortunately, the built-in Python binding automatically commits
...
...
@@ -126,14 +130,9 @@ class SQLiteDatabaseManager(DatabaseManager):
q
(
"CREATE TABLE IF NOT EXISTS config ("
" name TEXT NOT NULL PRIMARY KEY,"
" value TEXT)"
)
self
.
_setConfiguration
(
"version"
,
self
.
VERSION
)
else
:
# Automatic migration.
version
=
self
.
_getVersion
()
if
version
<
1
:
self
.
_checkNoUnfinishedTransactions
()
q
(
"DROP TABLE IF EXISTS ttrans"
)
self
.
_setConfiguration
(
"version"
,
self
.
VERSION
)
self
.
migrate
()
# The table "pt" stores a partition table.
q
(
"""CREATE TABLE IF NOT EXISTS pt (
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment