"""add plytix file queue

Revision ID: 0006_add_plytix_file_queue
Revises: 0005_backfill_attribute_def_options_json
Create Date: 2026-01-24 01:20:00.000000
"""

from alembic import op
import sqlalchemy as sa


revision = "0006_add_plytix_file_queue"
down_revision = "0005_backfill_attribute_def_options_json"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.create_table(
        "plytix_file_queue",
        sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
        sa.Column("label", sa.String(length=128), nullable=False),
        sa.Column("file_path", sa.Text(), nullable=False),
        sa.Column("file_name", sa.String(length=255), nullable=False),
        sa.Column("file_mtime", sa.Numeric(20, 6), nullable=False),
        sa.Column("file_size", sa.Integer()),
        sa.Column("status", sa.String(length=32), nullable=False, server_default="new"),
        sa.Column("last_error", sa.Text()),
        sa.Column("discovered_at", sa.DateTime(timezone=True)),
        sa.Column("processed_at", sa.DateTime(timezone=True)),
    )
    op.create_unique_constraint(
        "uq_plytix_file_queue_path_mtime",
        "plytix_file_queue",
        ["file_path", "file_mtime"],
    )


def downgrade() -> None:
    op.drop_constraint("uq_plytix_file_queue_path_mtime", "plytix_file_queue", type_="unique")
    op.drop_table("plytix_file_queue")
