Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore dialects other than postgresql #70

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions alembic_postgresql_enum/compare_dispatch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import Iterable, Union

import alembic
Expand All @@ -16,6 +17,9 @@
from alembic_postgresql_enum.get_enum_data import get_defined_enums, get_declared_enums


log = logging.getLogger(f"alembic.{__name__}")


@alembic.autogenerate.comparators.dispatch_for("schema")
def compare_enums(
autogen_context: AutogenContext,
Expand All @@ -28,6 +32,12 @@ def compare_enums(
for each defined enum that has changed new entries when compared to its
declared version.
"""
if autogen_context.dialect.name != "postgresql":
log.warning(
f"This library only supports postgresql, but you are using {autogen_context.dialect.name}, skipping"
)
return

add_create_type_false(upgrade_ops)
add_postgres_using_to_text(upgrade_ops)

Expand Down
10 changes: 10 additions & 0 deletions alembic_postgresql_enum/operations/sync_enum_values.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import List, Tuple, Any, Iterable, TYPE_CHECKING

import alembic.autogenerate
Expand Down Expand Up @@ -31,6 +32,9 @@
from alembic_postgresql_enum.get_enum_data import TableReference, ColumnType


log = logging.getLogger(f"alembic.{__name__}")


@alembic.operations.base.Operations.register_operation("sync_enum_values")
class SyncEnumValuesOp(alembic.operations.ops.MigrateOperation):
operation_name = "change_enum_variants"
Expand Down Expand Up @@ -138,6 +142,12 @@ def sync_enum_values(
]
If there was server default with old_name it will be renamed accordingly
"""
if operations.migration_context.dialect.name != "postgresql":
log.warning(
f"This library only supports postgresql, but you are using {operations.migration_context.dialect.name}, skipping"
)
return

enum_values_to_rename = list(enum_values_to_rename)

with get_connection(operations) as connection:
Expand Down
Loading