asyncpg-trek
A simple migrations system for asyncpg
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.8 or later and an existing asyncpg connection to a PostgreSQL database.
- 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 · maintenance · safety
MIT (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
last release 2024-07-19 (756 days) · last repo commit 2025-05-07 · 13 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 250,166 downloads/mo, #8,637 on PyPI
Alternatives
Verify before relying
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)- 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.
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 on this page. Verify before relying on it.
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
asyncpg-trek on PyPI
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.
Requires Python 3.8 or later and an existing asyncpg connection to a PostgreSQL database.
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)
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 the current Python release <4,>=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetyping_extensions |
| Maintenance | Aging 756 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 250,166 / month, #8,637 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaEnvironment :: Web EnvironmentFramework :: AsyncIOIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Typing :: Typed |
Evidence: asyncpg_trek-0.4.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “asyncpg migrations”
- asyncpg-trekManages database migrations for asyncpg by executing raw SQL or…
- asyncpg-stubsProvides type stubs for asyncpg to enable static type checking and…
- buildpgbuildpg constructs PostgreSQL prepared statements with named…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also asyncpg · databases · django-pg-zero-downtime-migrations · pysqlsync · yoyo-migrations · atlas-provider-sqlalchemy · alembic · clickhouse-migrations · migra · piccolo