"""Add event history table

Revision ID: 7ff555686ac3
Revises: 278e6319bf31
Create Date: 2025-11-22 11:40:33.396563

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils


# revision identifiers, used by Alembic.
revision: str = "7ff555686ac3"
down_revision: Union[str, Sequence[str], None] = "278e6319bf31"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "account_event_history",
        sa.Column("id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
        sa.Column("account_id", sa.Integer(), nullable=False),
        sa.Column("event_type", sa.String(length=10), nullable=False),
        sa.Column("data", sa.JSON(), nullable=False),
        sa.Column("actor", sa.String(), nullable=False),
        sa.Column("status", sa.String(length=10), nullable=False),
        sa.ForeignKeyConstraint(["account_id"], ["account.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )


def downgrade() -> None:
    """Downgrade schema."""
    op.drop_table("account_event_history")
