async def db_engine(skip_if_no_db):
    """Create a test database engine for each test function."""
    test_db_url = os.environ.get(
        "TEST_DATABASE_URL", "postgresql+asyncpg://airweave:airweave1234!@localhost:5432/airweave"
    )

    engine = create_async_engine(test_db_url, echo=True, poolclass=StaticPool, connect_args={
        "server_settings": {"jit": "off"}
    })

    # Create all tables
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)

    yield engine

    # Drop all tables after each test
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.drop_all)

    await engine.dispose()
Create a test database engine for each test function.
backend/tests/conftest.py