Skip to content

Commit

Permalink
Update migration
Browse files Browse the repository at this point in the history
  • Loading branch information
erosselli committed Oct 18, 2024
1 parent bc57101 commit 88b77a6
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
"""
)

Expand Down

0 comments on commit 88b77a6

Please sign in to comment.