--- id: asyncpg-trek version: "0.4.0" license: MIT license_treatment: permissive maintenance: aging --- # asyncpg-trek — A simple migrations system for asyncpg License: permissive · Maintenance: aging · Downloads: 250.2K/mo ## What it is and what it does asyncpg-trek is a lightweight migration tool for developers using asyncpg who want to write migrations as raw SQL or Python rather than adopting a heavier framework. It scans a folder you designate for migration files, tracks which ones have been applied to your database, and executes the necessary migrations to reach a target version—either upgrading, downgrading, or doing nothing if already at the target. The library is API-centric rather than CLI-driven: you write the code that calls it, controlling how the database connection is created and when migrations run. This makes it straightforward to integrate into tests, Docker entrypoints, admin endpoints, or application startup routines. It requires Python 3.8 or later and depends only on typing_extensions at runtime. Use it for: - Running migrations on application startup by specifying a hardcoded target revision for simple deployments. - Wrapping migrations in a custom CLI or admin HTTP endpoint to manage schema changes in complex systems. - Executing migrations in test fixtures to ensure a clean, versioned schema for each test run. - Downgrading to a previous schema version when rolling back a deployment. - Integrating migrations into a Docker image entrypoint for containerized applications. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Manages database migrations for asyncpg by executing raw SQL or Python files in a specified folder, with async support and declarative version targeting. Yes, if you use asyncpg and prefer raw SQL migrations without the overhead of SQLAlchemy/Alembic. The low install friction, permissive license, and straightforward API make it a reasonable choice for projects that fit its design. However, the Alpha status and lack of updates since July 2024 mean you should verify that it handles your specific migration patterns and be prepared to maintain it yourself if issues arise. ## Install pip install asyncpg-trek uv add asyncpg-trek poetry add asyncpg-trek ## Installing asyncpg-trek Before you install: Low install friction with a single runtime dependency (typing_extensions). The package is in Alpha status and has not been updated since July 2024, though the repository remains active. License in practice: MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects. Quickstart: from pathlib import Path import asyncpg from asyncpg_trek import plan, execute, Direction from asyncpg_trek.asyncpg import AsyncpgBackend MIGRATIONS_DIR = Path(__file__).parent / "migrations" async def migrate(conn: asyncpg.Connection, target_revision: str) -> None: backend = AsyncpgBackend(conn) async with backend.connect() as conn: planned = await plan(conn, backend, MIGRATIONS_DIR, target_revision=target_revision, direction=Direction.up) await execute(conn, backend, planned) Requires Python 3.8 or later and an existing asyncpg connection to a PostgreSQL database. Verify before relying: - Whether the package handles complex migration scenarios like rollbacks, dependencies between migrations, or conflict resolution. - Performance characteristics when managing large numbers of migrations. - Community adoption and whether issues are actively addressed beyond the original author. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 250.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags asyncpg migrations, postgres migrations async, sql migrations asyncpg, database schema versioning, async database migrations, raw sql migrations, asyncpg schema management, asyncpg, migrations, postgres [View on SkillFed](https://skillfed.io/packages/asyncpg-trek) · [View on PyPI](https://pypi.org/project/asyncpg-trek/)