Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
eae7c6db
Verified
Commit
eae7c6db
authored
4 months ago
by
Martin Weise
Browse files
Options
Downloads
Patches
Plain Diff
Updated the data script
Signed-off-by:
Martin Weise
<
martin.weise@tuwien.ac.at
>
parent
61382bb6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dbrepo-metadata-db/migration/16/data.py
+40
-40
40 additions, 40 deletions
dbrepo-metadata-db/migration/16/data.py
with
40 additions
and
40 deletions
dbrepo-metadata-db/migration/16/data.py
+
40
−
40
View file @
eae7c6db
...
...
@@ -18,8 +18,8 @@ def update_concepts() -> None:
for
concept
in
client
.
get_concepts
():
old_id
:
int
=
concept
.
id
new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_columns_concepts SET id =
'
{
new_id
}
'
WHERE id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_concepts SET id =
'
{
new_id
}
'
WHERE id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_concepts SET id =
'
{
new_id
}
'
WHERE id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_concepts SET id =
'
{
new_id
}
'
WHERE id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
"
COMMIT;
"
)
...
...
@@ -36,8 +36,8 @@ def update_units() -> None:
for
unit
in
client
.
get_units
():
old_id
:
int
=
unit
.
id
new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_columns_units SET id =
'
{
new_id
}
'
WHERE id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_units SET id =
'
{
new_id
}
'
WHERE id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_units SET id =
'
{
new_id
}
'
WHERE id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_units SET id =
'
{
new_id
}
'
WHERE id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
"
COMMIT;
"
)
...
...
@@ -47,10 +47,10 @@ def update_images() -> None:
for
image
in
client
.
get_images
():
old_id
:
int
=
image
.
id
new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_images SET id =
'
{
new_id
}
'
WHERE id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_image_operators SET id = UUID(), image_id =
'
{
new_id
}
'
WHERE image_id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_image_types SET id = UUID(), image_id =
'
{
new_id
}
'
WHERE image_id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_containers SET id = UUID(), image_id =
'
{
new_id
}
'
WHERE image_id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_images SET id =
'
{
new_id
}
'
WHERE id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_image_operators SET id = UUID(), image_id =
'
{
new_id
}
'
WHERE image_id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_image_types SET id = UUID(), image_id =
'
{
new_id
}
'
WHERE image_id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_containers SET id = UUID(), image_id =
'
{
new_id
}
'
WHERE image_id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
"
COMMIT;
"
)
...
...
@@ -60,8 +60,8 @@ def update_containers() -> None:
for
containers
in
client
.
get_containers
():
old_id
:
int
=
containers
.
id
new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_containers SET id =
'
{
new_id
}
'
WHERE id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_databases SET cid =
'
{
new_id
}
'
WHERE cid =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_containers SET id =
'
{
new_id
}
'
WHERE id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_databases SET cid =
'
{
new_id
}
'
WHERE cid =
'
{
old_id
}
'
;
"
)
plan
.
append
(
"
COMMIT;
"
)
...
...
@@ -72,30 +72,30 @@ def update_databases() -> None:
database
=
client
.
get_database
(
database_id
=
_database
.
id
)
old_id
:
int
=
database
.
id
new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_tables SET tDBID =
'
{
new_id
}
'
WHERE tDBID =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_have_access SET database_id =
'
{
new_id
}
'
WHERE database_id =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_view SET vdbid =
'
{
new_id
}
'
WHERE vdbid =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifiers SET dbid =
'
{
new_id
}
'
WHERE dbid =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_access SET aDBID =
'
{
new_id
}
'
WHERE aDBID =
{
old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_tables SET tDBID =
'
{
new_id
}
'
WHERE tDBID =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_have_access SET database_id =
'
{
new_id
}
'
WHERE database_id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_view SET vdbid =
'
{
new_id
}
'
WHERE vdbid =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifiers SET dbid =
'
{
new_id
}
'
WHERE dbid =
'
{
old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_access SET aDBID =
'
{
new_id
}
'
WHERE aDBID =
'
{
old_id
}
'
;
"
)
for
view
in
database
.
views
:
v_old_id
:
int
=
view
.
id
v_new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_identifiers SET vid =
'
{
v_new_id
}
'
WHERE vid =
{
v_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_view_columns SET id = UUID(), view_id =
'
{
v_new_id
}
'
WHERE id =
{
v_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifiers SET vid =
'
{
v_new_id
}
'
WHERE vid =
'
{
v_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_view_columns SET id = UUID(), view_id =
'
{
v_new_id
}
'
WHERE id =
'
{
v_old_id
}
'
;
"
)
for
table
in
database
.
tables
:
tbl_old_id
:
int
=
table
.
id
tbl_new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_identifiers SET tid =
'
{
tbl_new_id
}
'
WHERE tid =
{
tbl_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifiers SET tid =
'
{
tbl_new_id
}
'
WHERE tid =
'
{
tbl_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_checks SET id = UUID(), tid =
'
{
tbl_new_id
}
'
WHERE tid =
{
tbl_old_id
}
;
"
)
f
"
UPDATE mdb_constraints_checks SET id = UUID(), tid =
'
{
tbl_new_id
}
'
WHERE tid =
'
{
tbl_old_id
}
'
;
"
)
for
fk
in
table
.
constraints
.
foreign_keys
:
fk_old_id
:
int
=
fk
.
id
fk_new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_constraints_foreign_key SET id =
'
{
fk_new_id
}
'
, tid =
'
{
tbl_new_id
}
'
WHERE id =
{
fk_old_id
}
;
"
)
f
"
UPDATE mdb_constraints_foreign_key SET id =
'
{
fk_new_id
}
'
, tid =
'
{
tbl_new_id
}
'
WHERE id =
'
{
fk_old_id
}
'
;
"
)
for
fkref
in
fk
.
references
:
plan
.
append
(
f
"
UPDATE mdb_constraints_foreign_key_reference SET id = UUID(), fkid =
'
{
fk_new_id
}
'
WHERE fkid =
{
fkref
}
;
"
)
f
"
UPDATE mdb_constraints_foreign_key_reference SET id = UUID(), fkid =
'
{
fk_new_id
}
'
WHERE fkid =
'
{
fkref
}
'
;
"
)
for
pk
in
table
.
constraints
.
primary_key
:
pk_old_id
:
int
=
pk
.
id
plan
.
append
(
...
...
@@ -104,25 +104,25 @@ def update_databases() -> None:
uk_old_id
:
int
=
uk
.
id
uk_new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_constraints_unique SET uid =
'
{
uk_new_id
}
'
, tid =
'
{
tbl_new_id
}
'
WHERE uid =
{
uk_old_id
}
;
"
)
f
"
UPDATE mdb_constraints_unique SET uid =
'
{
uk_new_id
}
'
, tid =
'
{
tbl_new_id
}
'
WHERE uid =
'
{
uk_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_unique_columns SET id = UUID(), uid =
'
{
uk_new_id
}
'
WHERE uid =
{
uk_old_id
}
;
"
)
f
"
UPDATE mdb_constraints_unique_columns SET id = UUID(), uid =
'
{
uk_new_id
}
'
WHERE uid =
'
{
uk_old_id
}
'
;
"
)
for
column
in
table
.
columns
:
col_old_id
:
int
=
column
.
id
col_new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_columns SET ID =
'
{
col_new_id
}
'
WHERE ID =
{
col_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_unique_columns SET cid =
'
{
col_new_id
}
'
WHERE cid =
{
col_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_primary_key SET cid =
'
{
col_new_id
}
'
WHERE cid =
{
col_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns SET ID =
'
{
col_new_id
}
'
WHERE ID =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_unique_columns SET cid =
'
{
col_new_id
}
'
WHERE cid =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_primary_key SET cid =
'
{
col_new_id
}
'
WHERE cid =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_foreign_key_reference SET cid =
'
{
col_new_id
}
'
WHERE cid =
{
col_old_id
}
;
"
)
f
"
UPDATE mdb_constraints_foreign_key_reference SET cid =
'
{
col_new_id
}
'
WHERE cid =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_foreign_key_reference SET rcid =
'
{
col_new_id
}
'
WHERE rcid =
{
col_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_concepts SET cID =
'
{
col_new_id
}
'
WHERE cID =
{
col_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_units SET cID =
'
{
col_new_id
}
'
WHERE cID =
{
col_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_sets SET column_id =
'
{
col_new_id
}
'
WHERE column_id =
{
col_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_enums SET column_id =
'
{
col_new_id
}
'
WHERE column_id =
{
col_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_tables SET ID =
'
{
tbl_new_id
}
'
WHERE ID =
{
tbl_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_databases SET id =
'
{
new_id
}
'
WHERE id =
{
old_id
}
;
"
)
f
"
UPDATE mdb_constraints_foreign_key_reference SET rcid =
'
{
col_new_id
}
'
WHERE rcid =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_concepts SET cID =
'
{
col_new_id
}
'
WHERE cID =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_units SET cID =
'
{
col_new_id
}
'
WHERE cID =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_sets SET column_id =
'
{
col_new_id
}
'
WHERE column_id =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_columns_enums SET column_id =
'
{
col_new_id
}
'
WHERE column_id =
'
{
col_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_tables SET ID =
'
{
tbl_new_id
}
'
WHERE ID =
'
{
tbl_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_databases SET id =
'
{
new_id
}
'
WHERE id =
'
{
old_id
}
'
;
"
)
plan
.
append
(
"
COMMIT;
"
)
...
...
@@ -139,12 +139,12 @@ def update_identifiers() -> None:
for
identified
in
client
.
get_identifiers
():
i_old_id
:
int
=
identified
.
id
i_new_id
:
uuid
=
uuid
.
uuid4
()
plan
.
append
(
f
"
UPDATE mdb_identifiers SET ID =
'
{
i_new_id
}
'
WHERE id =
{
i_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_creators SET id = UUID(), pid =
'
{
i_new_id
}
'
WHERE pid =
{
i_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_descriptions SET id = UUID(), pid =
'
{
i_new_id
}
'
WHERE pid =
{
i_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_titles SET id = UUID(), pid =
'
{
i_new_id
}
'
WHERE pid =
{
i_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_funders SET id = UUID(), pid =
'
{
i_new_id
}
'
WHERE pid =
{
i_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_licenses SET pid =
'
{
i_new_id
}
'
WHERE pid =
{
i_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifiers SET ID =
'
{
i_new_id
}
'
WHERE id =
'
{
i_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_creators SET id = UUID(), pid =
'
{
i_new_id
}
'
WHERE pid =
'
{
i_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_descriptions SET id = UUID(), pid =
'
{
i_new_id
}
'
WHERE pid =
'
{
i_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_titles SET id = UUID(), pid =
'
{
i_new_id
}
'
WHERE pid =
'
{
i_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_funders SET id = UUID(), pid =
'
{
i_new_id
}
'
WHERE pid =
'
{
i_old_id
}
'
;
"
)
plan
.
append
(
f
"
UPDATE mdb_identifier_licenses SET pid =
'
{
i_new_id
}
'
WHERE pid =
'
{
i_old_id
}
'
;
"
)
plan
.
append
(
"
COMMIT;
"
)
def
finish_schema
()
->
None
:
...
...
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