"""0017 dashboard device check history Revision ID: 0017 Revises: 0016 Create Date: 2026-05-05 """ from alembic import op import sqlalchemy as sa revision = "0017" down_revision = "0016" branch_labels = None depends_on = None def upgrade() -> None: op.create_table( "dashboard_device_check_history", sa.Column("id", sa.Integer(), primary_key=True), sa.Column("device_id", sa.Integer(), sa.ForeignKey("devices.id", ondelete="CASCADE"), nullable=False), sa.Column( "check_key", sa.String(length=64), sa.ForeignKey("dashboard_check_definitions.check_key", ondelete="CASCADE"), nullable=False, ), sa.Column("status", sa.String(length=20), nullable=False), sa.Column("ping_ms", sa.Integer(), nullable=True), sa.Column("checked_at", sa.DateTime(timezone=True), nullable=False), sa.Column("duration_ms", sa.Integer(), nullable=True), sa.Column("error", sa.Text(), nullable=True), sa.Column("source", sa.String(length=32), nullable=False, server_default="dashboard_monitor"), ) op.create_index( "ix_dashboard_device_check_history_device_id", "dashboard_device_check_history", ["device_id"], ) op.create_index( "ix_dashboard_device_check_history_check_key", "dashboard_device_check_history", ["check_key"], ) op.create_index( "ix_dashboard_device_check_history_checked_at", "dashboard_device_check_history", ["checked_at"], ) def downgrade() -> None: op.drop_index("ix_dashboard_device_check_history_checked_at", table_name="dashboard_device_check_history") op.drop_index("ix_dashboard_device_check_history_check_key", table_name="dashboard_device_check_history") op.drop_index("ix_dashboard_device_check_history_device_id", table_name="dashboard_device_check_history") op.drop_table("dashboard_device_check_history")