"""add status_updated_at to organizations

Revision ID: 90ceeb8168c2
Revises: bf0f120ca9a9
Create Date: 2025-09-16 15:53:27.802306

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "90ceeb8168c2"
down_revision = "bf0f120ca9a9"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "organizations",
        sa.Column("status_updated_at", sa.TIMESTAMP(timezone=True), nullable=True),
    )

    op.execute(
        "UPDATE organizations SET status_updated_at = modified_at WHERE status_updated_at IS NULL"
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("organizations", "status_updated_at")
    # ### end Alembic commands ###
