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
Container Registry
Model registry
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
Maunium
synapse
Commits
17d319a2
Commit
17d319a2
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
s/schema_deltas/applied_schema_deltas/
parent
5681264f
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/storage/__init__.py
+9
-7
9 additions, 7 deletions
synapse/storage/__init__.py
synapse/storage/schema/schema_version.sql
+2
-2
2 additions, 2 deletions
synapse/storage/schema/schema_version.sql
with
11 additions
and
9 deletions
synapse/storage/__init__.py
+
9
−
7
View file @
17d319a2
...
...
@@ -674,12 +674,13 @@ def _setup_new_database(cur):
_upgrade_existing_database
(
cur
,
current_version
=
max_current_ver
,
delta_files
=
[],
applied_
delta_files
=
[],
upgraded
=
False
)
def
_upgrade_existing_database
(
cur
,
current_version
,
delta_files
,
upgraded
):
def
_upgrade_existing_database
(
cur
,
current_version
,
applied_delta_files
,
upgraded
):
"""
Upgrades an existing database.
Delta files can either be SQL stored in *.sql files, or python modules
...
...
@@ -712,8 +713,9 @@ def _upgrade_existing_database(cur, current_version, delta_files, upgraded):
Args:
cur (Cursor)
current_version (int): The current version of the schema
delta_files (list): A list of deltas that have already been applied
current_version (int): The current version of the schema.
applied_delta_files (list): A list of deltas that have already been
applied.
upgraded (bool): Whether the current version was generated by having
applied deltas or from full schema file. If `True` the function
will never apply delta files for the given `current_version`, since
...
...
@@ -746,7 +748,7 @@ def _upgrade_existing_database(cur, current_version, delta_files, upgraded):
directory_entries
.
sort
()
for
file_name
in
directory_entries
:
relative_path
=
os
.
path
.
join
(
str
(
v
),
file_name
)
if
relative_path
in
delta_files
:
if
relative_path
in
applied_
delta_files
:
continue
absolute_path
=
os
.
path
.
join
(
...
...
@@ -781,7 +783,7 @@ def _upgrade_existing_database(cur, current_version, delta_files, upgraded):
# Mark as done.
cur
.
execute
(
"
INSERT INTO schema_deltas (version, file)
"
"
INSERT INTO
applied_
schema_deltas (version, file)
"
"
VALUES (?,?)
"
,
(
v
,
relative_path
)
)
...
...
@@ -807,7 +809,7 @@ def _get_or_create_schema_state(txn):
if
current_version
:
txn
.
execute
(
"
SELECT file FROM schema_deltas WHERE version >= ?
"
,
"
SELECT file FROM
applied_
schema_deltas WHERE version >= ?
"
,
(
current_version
,)
)
return
current_version
,
txn
.
fetchall
(),
upgraded
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/schema/schema_version.sql
+
2
−
2
View file @
17d319a2
...
...
@@ -21,10 +21,10 @@ CREATE TABLE IF NOT EXISTS schema_version(
CONSTRAINT
schema_version_lock_uniq
UNIQUE
(
Lock
)
);
CREATE
TABLE
IF
NOT
EXISTS
schema_deltas
(
CREATE
TABLE
IF
NOT
EXISTS
applied_
schema_deltas
(
version
INTEGER
NOT
NULL
,
file
TEXT
NOT
NULL
,
CONSTRAINT
schema_deltas_ver_file
UNIQUE
(
version
,
file
)
ON
CONFLICT
IGNORE
);
CREATE
INDEX
IF
NOT
EXISTS
schema_deltas_ver
ON
schema_deltas
(
version
);
CREATE
INDEX
IF
NOT
EXISTS
schema_deltas_ver
ON
applied_
schema_deltas
(
version
);
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