From eae7c6db7ce923198ea9b735ab388061dd4b8f87 Mon Sep 17 00:00:00 2001
From: Martin Weise <martin.weise@tuwien.ac.at>
Date: Mon, 24 Feb 2025 11:12:11 +0100
Subject: [PATCH] Updated the data script

Signed-off-by: Martin Weise <martin.weise@tuwien.ac.at>
---
 dbrepo-metadata-db/migration/16/data.py | 80 ++++++++++++-------------
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/dbrepo-metadata-db/migration/16/data.py b/dbrepo-metadata-db/migration/16/data.py
index 796d025a75..c76a5a72d5 100644
--- a/dbrepo-metadata-db/migration/16/data.py
+++ b/dbrepo-metadata-db/migration/16/data.py
@@ -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:
-- 
GitLab