"""Add activated_at to CustomerMeter

Revision ID: 44c10a1f55db
Revises: 1b73becdc178
Create Date: 2025-12-10 13:35:02.739317

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "44c10a1f55db"
down_revision = "1b73becdc178"
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(
        "customer_meters",
        sa.Column("activated_at", sa.TIMESTAMP(timezone=True), nullable=True),
    )
    op.execute("UPDATE customer_meters SET activated_at = NOW()")
    op.create_index(
        op.f("ix_customer_meters_activated_at"),
        "customer_meters",
        ["activated_at"],
        unique=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_customer_meters_activated_at"), table_name="customer_meters")
    op.drop_column("customer_meters", "activated_at")
    # ### end Alembic commands ###
