"""Add scheduled field to sync_job table

Revision ID: 25e5ed7e5b9f
Revises: aafff4b827f4
Create Date: 2025-08-21 20:29:42.070349

"""

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "25e5ed7e5b9f"
down_revision = "aafff4b827f4"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###

    op.drop_index(op.f("ix_sync_sync_type"), table_name="sync")
    op.drop_index(op.f("ix_sync_temporal_schedule_id"), table_name="sync")
    # Add column with server_default to ensure no NULLs during migration
    op.add_column(
        "sync_job",
        sa.Column("scheduled", sa.Boolean(), nullable=False, server_default=sa.text("FALSE")),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("sync_job", "scheduled")
    op.create_index(
        op.f("ix_sync_temporal_schedule_id"), "sync", ["temporal_schedule_id"], unique=False
    )
    op.create_index(op.f("ix_sync_sync_type"), "sync", ["sync_type"], unique=False)
    # ### end Alembic commands ###
