configure-alembic-async-ddl

Configure Alembic migrations for async SQLAlchemy applications with sync DDL connections.

Updated May 15, 2026
One-click install
npx skills add https://github.com/ruskibeats/t1d --skill configure-alembic-async-ddl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: configure-alembic-async-ddl
Source: https://github.com/ruskibeats/t1d/tree/main/.pi/skills-archive/configure-alembic-async-ddl
Command: npx skills add https://github.com/ruskibeats/t1d --skill configure-alembic-async-ddl

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires psycopg2-binary, and includes scripts (resource) components.

What problem does it solve?

This Skill helps configure Alembic migrations for async SQLAlchemy applications, ensuring compatibility with async SQLAlchemy engines while using sync DDL connections.

Core Features & Use Cases

  • DDL Compatibility: Strips async driver suffix for DDL-compatible sync connections.
  • Target Metadata Wiring: Wiring target_metadata to the actual MetaData object.
  • NullPool for Migrations: Using NullPool for migration connections.
  • Online & Offline Modes: Supports both online and offline migration operations.
  • Verification: Includes verification steps to ensure correct DDL changes are detected.

Quick Start

To configure Alembic for async SQLAlchemy, first identify your MetaData object, then in env.py, strip the async driver suffix from the connection string. Wire the target_metadata to your MetaData object, and create a sync engine for online migrations using NullPool.

Frequently Asked Questions about configure-alembic-async-ddl

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Alembic migrations for async SQLAlchemy applications without conflicts?

Configuring Alembic migrations for async SQLAlchemy requires stripping the async driver suffix from the connection string for sync DDL compatibility, wiring target_metadata to your MetaData object, and using NullPool for migration connections.

Why does Alembic fail to run migrations with my async FastAPI SQLAlchemy engine?

Alembic fails with async FastAPI SQLAlchemy engines because DDL operations require synchronous connections. You must strip the async driver suffix from the connection string and create a sync engine specifically for executing migration operations.

Do I need psycopg2-binary to run Alembic migrations with async SQLAlchemy?

Yes, psycopg2-binary is required for synchronous DDL execution. Alembic migrations need a sync database connection to apply schema changes, even when your primary application uses an async SQLAlchemy engine.

How do I wire target_metadata to my MetaData object in Alembic env.py?

Wiring target_metadata in Alembic env.py involves pointing the variable to your actual SQLAlchemy MetaData object rather than a generic or empty one. This ensures Alembic's autogenerate feature detects the correct DDL changes for verification.

Can I use Alembic offline and online migration modes with an async SQLAlchemy setup?

Yes, async SQLAlchemy setups support both offline and online Alembic migration modes. For online migrations, you create a sync engine using NullPool to execute DDL statements, while offline mode generates SQL scripts without a live database connection.

What is NullPool used for when running Alembic migrations with SQLAlchemy?

NullPool is used for migration connections in SQLAlchemy to prevent the connection pool from retaining database connections. This ensures clean, single-use connections for executing DDL operations during Alembic migrations without async engine conflicts.