"""Make Schedule start and end timezone aware

Revision ID: 803938b158ce
Revises: e5024a57ff6e
Create Date: 2025-11-24 10:58:24.004341

"""

from collections.abc import Sequence

import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "803938b158ce"
down_revision: str | None = "e5024a57ff6e"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "schedule",
        "start_at",
        existing_type=postgresql.TIMESTAMP(),
        type_=sa.TIMESTAMP(timezone=True),
        existing_nullable=True,
        postgresql_using="start_at AT TIME ZONE 'UTC'",
    )
    op.alter_column(
        "schedule",
        "end_at",
        existing_type=postgresql.TIMESTAMP(),
        type_=sa.TIMESTAMP(timezone=True),
        existing_nullable=True,
        postgresql_using="end_at AT TIME ZONE 'UTC'",
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "schedule",
        "end_at",
        existing_type=sa.TIMESTAMP(timezone=True),
        type_=postgresql.TIMESTAMP(),
        existing_nullable=True,
        postgresql_using="end_at AT TIME ZONE 'UTC'",
    )
    op.alter_column(
        "schedule",
        "start_at",
        existing_type=sa.TIMESTAMP(timezone=True),
        type_=postgresql.TIMESTAMP(),
        existing_nullable=True,
        postgresql_using="start_at AT TIME ZONE 'UTC'",
    )
    # ### end Alembic commands ###
