"""Initial migration

Revision ID: 5186177178db
Revises:
Create Date: 2026-02-07 14:12:11.740022

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "5186177178db"
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "crawler_state",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("crawl_job_running", sa.Boolean(), nullable=False),
        sa.Column("crawl_job_type", sa.String(), nullable=True),
        sa.Column("crawl_job_started_at", sa.DateTime(), nullable=True),
        sa.Column("monitoring_active", sa.Boolean(), nullable=False),
        sa.Column("files_discovered", sa.Integer(), nullable=False),
        sa.Column("files_indexed", sa.Integer(), nullable=False),
        sa.Column("files_error", sa.Integer(), nullable=False),
        sa.Column("files_deleted", sa.Integer(), nullable=False),
        sa.Column("files_skipped", sa.Integer(), nullable=False),
        sa.Column("estimated_total_files", sa.Integer(), nullable=False),
        sa.Column("discovery_progress", sa.Integer(), nullable=False),
        sa.Column("indexing_progress", sa.Integer(), nullable=False),
        sa.Column("last_activity", sa.DateTime(), nullable=True),
        sa.Column("estimated_completion", sa.DateTime(), nullable=True),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "settings",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("key", sa.String(), nullable=False),
        sa.Column("value", sa.Text(), nullable=False),
        sa.Column("description", sa.Text(), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_settings_id"), "settings", ["id"], unique=False)
    op.create_index(op.f("ix_settings_key"), "settings", ["key"], unique=True)
    op.create_table(
        "watch_paths",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("path", sa.String(), nullable=False),
        sa.Column("enabled", sa.Boolean(), nullable=False),
        sa.Column("include_subdirectories", sa.Boolean(), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("is_excluded", sa.Boolean(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_watch_paths_id"), "watch_paths", ["id"], unique=False)
    op.create_index(op.f("ix_watch_paths_path"), "watch_paths", ["path"], unique=True)
    op.create_table(
        "wizard_state",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("wizard_completed", sa.Boolean(), nullable=False),
        sa.Column("docker_check_passed", sa.Boolean(), nullable=False),
        sa.Column("docker_services_started", sa.Boolean(), nullable=False),
        sa.Column("collection_created", sa.Boolean(), nullable=False),
        sa.Column("last_step_completed", sa.Integer(), nullable=False),
        sa.Column("completed_at", sa.DateTime(), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("wizard_state")
    op.drop_index(op.f("ix_watch_paths_path"), table_name="watch_paths")
    op.drop_index(op.f("ix_watch_paths_id"), table_name="watch_paths")
    op.drop_table("watch_paths")
    op.drop_index(op.f("ix_settings_key"), table_name="settings")
    op.drop_index(op.f("ix_settings_id"), table_name="settings")
    op.drop_table("settings")
    op.drop_table("crawler_state")
    # ### end Alembic commands ###
