"""Add attempts + max_attempts to magento_sync_queue for crash recovery.

Revision ID: 0014_queue_attempts_stale_recovery
Revises: 0013_add_pull_queue_feed_events
Create Date: 2026-03-03
"""
from alembic import op
import sqlalchemy as sa

revision = "0014_queue_attempts_stale_recovery"
down_revision = "0013_add_pull_queue_feed_events"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "magento_sync_queue",
        sa.Column("attempts", sa.Integer(), nullable=False, server_default="0"),
    )
    op.add_column(
        "magento_sync_queue",
        sa.Column("max_attempts", sa.Integer(), nullable=False, server_default="3"),
    )


def downgrade() -> None:
    op.drop_column("magento_sync_queue", "max_attempts")
    op.drop_column("magento_sync_queue", "attempts")
