Skip to content

Commit

Permalink
HJ-56 - Add RDS Postgres to ConnectorType (#5382)
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-torres-marroquin authored Oct 15, 2024
1 parent 8174a84 commit 7038f61
Showing 1 changed file with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 7038f61

Please sign in to comment.