alembic

Version database schema changes with Alembic and SQLAlchemy for PostgreSQL.

Updated Jan 31, 2026
One-click install
npx skills add https://github.com/farhaduneci/url-shortener --skill alembic-farhaduneci
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: alembic
Source: https://github.com/farhaduneci/url-shortener/tree/main/.agents/skills/alembic
Command: npx skills add https://github.com/farhaduneci/url-shortener --skill alembic-farhaduneci

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Alembic provides a disciplined approach to evolving a database schema, enabling safe upgrades, rollbacks, and auditability for production systems.

Core Features & Use Cases

  • Version-controlled migrations: track schema changes across environments (development, staging, production) using Alembic and SQLAlchemy.
  • Auto-generated and manual migrations: generate migration scripts automatically from models or write custom scripts for complex changes; support data migrations inline.
  • Branching, merging, and multi-database workflows: coordinate migrations across teams and databases, including cross-branch collaboration and merge scenarios.

Quick Start

  1. Install dependencies: pip install alembic sqlalchemy psycopg2-binary pytest
  2. Initialize Alembic: alembic init alembic
  3. Configure database URL in alembic.ini or env.py and create your first revision: alembic revision -m "initial" and then alembic upgrade head
  4. Run migration tests: pytest

Frequently Asked Questions about alembic

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

FAQPage Schema
How do I manage database migrations safely with SQLAlchemy and PostgreSQL?

Database migrations are managed by versioning schema changes with Alembic, enabling safe upgrades, rollbacks, and auditability across PostgreSQL environments. It supports auto-generated and manual scripts to ensure reliable development and deployment.

How do I handle database schema branching and merging across teams?

Database schema branching and merging is handled using Alembic workflows that coordinate migrations across teams and databases. This approach supports cross-branch collaboration and merge scenarios to maintain schema integrity during development.

Can I run data migrations inline with schema changes in Alembic?

Yes, data migrations can run inline with schema changes. Alembic allows you to generate migration scripts automatically from models or write custom scripts for complex data transformations alongside standard schema updates.

What is the best way to test database migrations for reliability?

Testing database migrations for reliability is done using pytest. Writing and running migration tests with pytest ensures that schema upgrades, rollbacks, and data migrations perform safely before reaching production environments.

How do I set up Alembic for zero-downtime database version control?

Zero-downtime database version control is set up by installing Alembic with SQLAlchemy and psycopg2, initializing the environment, configuring the database URL, and running migration tests with pytest to guarantee safe deployment.

Does Alembic support auto-generated migration scripts from SQLAlchemy models?

Yes, Alembic supports auto-generated migration scripts from SQLAlchemy models. It tracks schema changes across development, staging, and production environments, and also allows writing custom scripts for complex modifications.