"""public ip monitor tables Revision ID: 20260429_05_public_ip_monitor Revises: 20260420_04_app_config_table Create Date: 2026-04-29 00:00:01.000000 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa revision: str = "20260429_05_public_ip_monitor" down_revision: Union[str, None] = "20260420_04_app_config_table" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table( "public_ip_history", sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), sa.Column("ipv4", sa.String(length=45), nullable=False), sa.Column("observed_at", sa.DateTime(timezone=True), nullable=False), sa.Column("change_type", sa.String(length=32), nullable=False), sa.Column("provider", sa.String(length=64), nullable=True), sa.PrimaryKeyConstraint("id"), ) op.create_index( "ix_public_ip_history_observed_at", "public_ip_history", ["observed_at"], unique=False, ) op.create_table( "public_ip_state", sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), sa.Column("current_ipv4", sa.String(length=45), nullable=False), sa.Column("previous_ipv4", sa.String(length=45), nullable=True), sa.Column("first_seen_at", sa.DateTime(timezone=True), nullable=False), sa.Column("last_checked_at", sa.DateTime(timezone=True), nullable=False), sa.Column("last_changed_at", sa.DateTime(timezone=True), nullable=True), sa.Column("last_check_status", sa.String(length=32), nullable=False), sa.Column("last_check_error", sa.String(length=255), nullable=True), sa.Column("last_provider", sa.String(length=64), nullable=True), sa.PrimaryKeyConstraint("id"), ) def downgrade() -> None: op.drop_table("public_ip_state") op.drop_index("ix_public_ip_history_observed_at", table_name="public_ip_history") op.drop_table("public_ip_history")