From 88b77a6f8adaaf38eb579561591f0e67db8efd7c Mon Sep 17 00:00:00 2001 From: Eliana Rosselli Date: Thu, 17 Oct 2024 12:17:45 -0300 Subject: [PATCH] Update migration --- ...1b_add_connection_type_to_dataset_namespace.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/fides/api/alembic/migrations/versions/4ebe0766021b_add_connection_type_to_dataset_namespace.py b/src/fides/api/alembic/migrations/versions/4ebe0766021b_add_connection_type_to_dataset_namespace.py index 5713225a9f..89faf10b66 100644 --- a/src/fides/api/alembic/migrations/versions/4ebe0766021b_add_connection_type_to_dataset_namespace.py +++ b/src/fides/api/alembic/migrations/versions/4ebe0766021b_add_connection_type_to_dataset_namespace.py @@ -19,13 +19,22 @@ def upgrade(): # Populate the connection_type field in the namespace meta for all datasets # that have a namespace key in their fides_meta json field. - # We use bigquery as the initial value since only datasets generated from - # BigQuery monitors will have a namespace key in their fides_meta json field. + + # If the namespace dict has a project_id key, we know it's a BigQuery dataset. op.execute( """ update ctl_datasets set fides_meta = jsonb_set(fides_meta::jsonb, '{namespace, connection_type}', '"bigquery"', true) - where fides_meta::jsonb ? 'namespace'; + where (fides_meta::jsonb ? 'namespace') and ((fides_meta::jsonb ->> 'namespace')::jsonb ? 'project_id'); + """ + ) + + # If the namespace dict has a database_instance_id, we know it's an RDS MySQL dataset. + op.execute( + """ + update ctl_datasets + set fides_meta = jsonb_set(fides_meta::jsonb, '{namespace, connection_type}', '"rds_mysql"', true) + where (fides_meta::jsonb ? 'namespace') and ((fides_meta::jsonb ->> 'namespace')::jsonb ? 'database_instance_id'); """ )