from __future__ import annotations

from pathlib import Path


def test_initial_migration_exists_and_creates_expected_tables() -> None:
    versions_dir = Path(__file__).resolve().parents[3] / "alembic" / "versions"
    migration_files = sorted(versions_dir.glob("20260226_*.py"))
    assert len(migration_files) == 5, "split initial migrations should exist"

    content = "\n".join(m.read_text(encoding="utf-8") for m in migration_files)

    # New tables from social data model redesign
    assert "create_table(" in content and "automation_jobs" in content
    assert "create_table(" in content and "user_agents" in content
    assert "create_table(" in content and "memories" in content
    assert "create_table(" in content and "friendships" in content
    assert "create_table(" in content and "groups" in content
    assert "create_table(" in content and "group_members" in content
    assert "create_table(" in content and "schedule_items" in content
    assert "create_table(" in content and "schedule_subscriptions" in content
    assert "create_table(" in content and "inbox_messages" in content
    assert "create_table(" in content and "todos" in content
    assert "create_table(" in content and "todo_sources" in content
    assert "create_table(" in content and "profiles" in content
    assert "create_table(" in content and "sessions" in content
    assert "create_table(" in content and "messages" in content
