"""Add channel to audit_log and frequency to notification_configs.

Revision ID: 051
Revises: 050
"""
from alembic import op
import sqlalchemy as sa

revision = "051"
down_revision = "050"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # Add channel column to audit_log
    op.add_column(
        "audit_log",
        sa.Column(
            "channel",
            sa.String(20),
            nullable=False,
            server_default="notification",
        ),
    )
    op.create_index("ix_audit_log_channel", "audit_log", ["channel"])

    # Add frequency column to notification_configs
    op.add_column(
        "notification_configs",
        sa.Column(
            "frequency",
            sa.String(20),
            nullable=False,
            server_default="immediate",
        ),
    )


def downgrade() -> None:
    op.drop_column("notification_configs", "frequency")
    op.drop_index("ix_audit_log_channel", table_name="audit_log")
    op.drop_column("audit_log", "channel")
