Skip to content

Commit

Permalink
migration to add s3 to db connection type enum
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsachs committed May 31, 2024
1 parent d2b80a8 commit 4c2154f
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""add s3 connection type
Revision ID: cb344673f633
Revises: 4b2eade4353c
Create Date: 2024-05-31 20:46:08.829330
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "cb344673f633"
down_revision = "4b2eade4353c"
branch_labels = None
depends_on = None


def upgrade():
# Add 's3' 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', 'dynamodb', 'postgres',"
"'generic_consent_email', 'generic_erasure_email', 's3')"
)
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 's3' from ConnectionType enum
op.execute("delete from connectionconfig where connection_type in ('s3')")
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', 'dynamodb', 'postgres',"
"'generic_consent_email', 'generic_erasure_email')"
)
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 4c2154f

Please sign in to comment.