"""Add approved_by, approved_at, rejection_reason to campaigns.

Revision ID: b054
Revises: b053
Create Date: 2026-07-02
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

revision = "b054"
down_revision = "b053"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "campaigns",
        sa.Column("approved_by", postgresql.UUID(as_uuid=True), nullable=True),
    )
    op.add_column("campaigns", sa.Column("approved_at", sa.DateTime(), nullable=True))
    op.add_column("campaigns", sa.Column("rejection_reason", sa.Text(), nullable=True))
    op.create_foreign_key(
        "fk_campaigns_approved_by_users",
        "campaigns", "users",
        ["approved_by"], ["id"],
        ondelete="SET NULL",
    )


def downgrade() -> None:
    op.drop_constraint("fk_campaigns_approved_by_users", "campaigns", type_="foreignkey")
    op.drop_column("campaigns", "rejection_reason")
    op.drop_column("campaigns", "approved_at")
    op.drop_column("campaigns", "approved_by")
