From 2c6c1f2772ab51f6961b332dc1061a3966fcbd56 Mon Sep 17 00:00:00 2001 From: Andres Torres Date: Tue, 15 Oct 2024 11:37:58 -0600 Subject: [PATCH] HJ-56 - Add RDS Postgres to ConnectorType (#5382) --- ...18ae_add_rds_postgres_to_connector_type.py | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/fides/api/alembic/migrations/versions/5dafbc1818ae_add_rds_postgres_to_connector_type.py diff --git a/src/fides/api/alembic/migrations/versions/5dafbc1818ae_add_rds_postgres_to_connector_type.py b/src/fides/api/alembic/migrations/versions/5dafbc1818ae_add_rds_postgres_to_connector_type.py new file mode 100644 index 00000000000..6f27b858b19 --- /dev/null +++ b/src/fides/api/alembic/migrations/versions/5dafbc1818ae_add_rds_postgres_to_connector_type.py @@ -0,0 +1,104 @@ +"""add_rds_postgres_to_connector_type + +Revision ID: 5dafbc1818ae +Revises: 49bdd2fff350 +Create Date: 2024-10-15 14:14:59.651766 + +""" + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "5dafbc1818ae" +down_revision = "49bdd2fff350" +branch_labels = None +depends_on = None + + +def upgrade(): + # Add 'rds_postgres' to ConnectionType enum + op.execute("ALTER TYPE connectiontype RENAME TO connectiontype_old") + op.execute( + """ + CREATE TYPE connectiontype AS ENUM ( + 'mongodb', + 'mysql', + 'https', + 'snowflake', + 'redshift', + 'mssql', + 'mariadb', + 'bigquery', + 'saas', + 'manual', + 'manual_webhook', + 'timescale', + 'fides', + 'sovrn', + 'attentive_email', + 'dynamodb', + 'postgres', + 'generic_consent_email', + 'generic_erasure_email', + 'scylla', + 's3', + 'google_cloud_sql_mysql', + 'google_cloud_sql_postgres', + 'dynamic_erasure_email', + 'rds_mysql', + 'rds_postgres' + ) + """ + ) + op.execute( + """ + ALTER TABLE connectionconfig ALTER COLUMN connection_type TYPE connectiontype USING + connection_type::text::connectiontype + """ + ) + op.execute("DROP TYPE connectiontype_old") + + +def downgrade(): + # Remove 'rds_postgres' from ConnectionType enum + op.execute("DELETE FROM connectionconfig WHERE connection_type IN ('rds_postgres')") + op.execute("ALTER TYPE connectiontype RENAME TO connectiontype_old") + op.execute( + """ + CREATE TYPE connectiontype AS ENUM ( + 'mongodb', + 'mysql', + 'https', + 'snowflake', + 'redshift', + 'mssql', + 'mariadb', + 'bigquery', + 'saas', + 'manual', + 'manual_webhook', + 'timescale', + 'fides', + 'sovrn', + 'attentive_email', + 'dynamodb', + 'postgres', + 'generic_consent_email', + 'generic_erasure_email', + 'scylla', + 's3', + 'google_cloud_sql_mysql', + 'google_cloud_sql_postgres', + 'dynamic_erasure_email', + 'rds_mysql' + ) + """ + ) + op.execute( + """ + ALTER TABLE connectionconfig ALTER COLUMN connection_type TYPE connectiontype USING + connection_type::text::connectiontype + """ + ) + op.execute("DROP TYPE connectiontype_old")