"""add busylight_pull_token_hash + created_at to companies

Revision ID: 0023
Revises: 0022
Create Date: 2026-05-06
"""
from alembic import op
import sqlalchemy as sa


revision = "0023"
down_revision = "0022"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "companies",
        sa.Column("busylight_pull_token_hash", sa.String(length=64), nullable=True),
    )
    op.add_column(
        "companies",
        sa.Column("busylight_token_created_at", sa.DateTime(timezone=True), nullable=True),
    )
    op.create_unique_constraint(
        "uq_companies_busylight_pull_token_hash",
        "companies",
        ["busylight_pull_token_hash"],
    )


def downgrade() -> None:
    op.drop_constraint("uq_companies_busylight_pull_token_hash", "companies", type_="unique")
    op.drop_column("companies", "busylight_token_created_at")
    op.drop_column("companies", "busylight_pull_token_hash")
