🩹 — Check before adding/removing ip_version_enum

This commit is contained in:
Luc Didry 2025-01-15 09:13:23 +01:00
parent 64f8241e74
commit 586660c02a
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
2 changed files with 4 additions and 2 deletions

View file

@ -3,6 +3,8 @@
## [Unreleased] ## [Unreleased]
- 🩹 — Avoid warning from MySQL only alembic instructions - 🩹 — Avoid warning from MySQL only alembic instructions
- 🩹 — Check before adding/removing ip_version_enum
## 0.7.0 ## 0.7.0

View file

@ -21,7 +21,7 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None: def upgrade() -> None:
enum = ENUM("4", "6", name="ip_version_enum", create_type=False) enum = ENUM("4", "6", name="ip_version_enum", create_type=False)
enum.create(op.get_bind(), checkfirst=False) enum.create(op.get_bind(), checkfirst=True)
with op.batch_alter_table("tasks", schema=None) as batch_op: with op.batch_alter_table("tasks", schema=None) as batch_op:
batch_op.add_column( batch_op.add_column(
sa.Column("ip_version", enum, server_default="4", nullable=False) sa.Column("ip_version", enum, server_default="4", nullable=False)
@ -31,4 +31,4 @@ def upgrade() -> None:
def downgrade() -> None: def downgrade() -> None:
with op.batch_alter_table("tasks", schema=None) as batch_op: with op.batch_alter_table("tasks", schema=None) as batch_op:
batch_op.drop_column("ip_version") batch_op.drop_column("ip_version")
ENUM(name="ip_version_enum").drop(op.get_bind(), checkfirst=False) ENUM(name="ip_version_enum").drop(op.get_bind(), checkfirst=True)