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
1f094b55
Verified
Commit
1f094b55
authored
4 months ago
by
Martin Weise
Browse files
Options
Downloads
Patches
Plain Diff
Updated data generation script
Signed-off-by:
Martin Weise
<
martin.weise@tuwien.ac.at
>
parent
eb6e9a6c
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
+20
-10
20 additions, 10 deletions
dbrepo-metadata-db/migration/16/data.py
with
20 additions
and
10 deletions
dbrepo-metadata-db/migration/16/data.py
+
20
−
10
View file @
1f094b55
...
...
@@ -4,9 +4,9 @@ import uuid
from
dbrepo.RestClient
import
RestClient
endpoint
=
os
.
getenv
(
'
METADATA_SERVICE_ENDPOINT
'
,
'
http://
localhos
t
'
)
endpoint
=
os
.
getenv
(
'
METADATA_SERVICE_ENDPOINT
'
,
'
http
s
://
dbrepo1.ec.tuwien.ac.a
t
'
)
username
=
os
.
getenv
(
'
SYSTEM_USERNAME
'
,
'
admin
'
)
password
=
os
.
getenv
(
'
SYSTEM_PASSWORD
'
,
'
admin
'
)
password
=
os
.
getenv
(
'
SYSTEM_PASSWORD
'
,
'
f24870437f82adf567c0b03179f15e21
'
)
client
=
RestClient
(
endpoint
=
endpoint
,
username
=
username
,
password
=
password
)
plan
:
[
str
]
=
[]
...
...
@@ -86,29 +86,37 @@ def update_databases() -> None:
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_constraints_checks SET id = UUID(), 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
}
;
"
)
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
}
;
"
)
plan
.
append
(
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
}
;
"
)
plan
.
append
(
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
(
f
"
UPDATE mdb_constraints_primary_key SET pkid = UUID(), tID =
'
{
tbl_new_id
}
'
WHERE tID =
{
pk_old_id
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_primary_key SET pkid = UUID(), tID =
'
{
tbl_new_id
}
'
WHERE tID =
{
pk_old_id
}
;
"
)
for
uk
in
table
.
constraints
.
uniques
:
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
}
;
"
)
plan
.
append
(
f
"
UPDATE mdb_constraints_unique_columns SET id = UUID(), uid =
'
{
uk_new_id
}
'
WHERE uid =
{
uk_old_id
}
;
"
)
plan
.
append
(
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
}
;
"
)
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_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_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
}
;
"
)
...
...
@@ -117,12 +125,14 @@ def update_databases() -> None:
plan
.
append
(
f
"
UPDATE mdb_databases SET id =
'
{
new_id
}
'
WHERE id =
{
old_id
}
;
"
)
plan
.
append
(
"
COMMIT;
"
)
def
update_messages
()
->
None
:
plan
.
append
(
"
-- messages
"
)
plan
.
append
(
"
BEGIN;
"
)
plan
.
append
(
f
"
UPDATE mdb_messages SET ID = UUID();
"
)
plan
.
append
(
"
COMMIT;
"
)
def
update_identifiers
()
->
None
:
plan
.
append
(
"
-- identifiers
"
)
plan
.
append
(
"
BEGIN;
"
)
...
...
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