oh-my-zsh-alembic

June 5, 2025 ยท View on GitHub

A comprehensive oh-my-zsh plugin for Alembic, the database migration tool for SQLAlchemy.

Features

  • Command aliases for faster workflow
  • Tab completion for all Alembic commands and options
  • Helper functions for common operations
  • Status overview functions
  • Support for Alembic 1.16.1+

Installation

Using oh-my-zsh custom plugins

  1. Clone this repository into your oh-my-zsh custom plugins directory:

    git clone https://github.com/datumbrain/oh-my-zsh-alembic.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/alembic
    
  2. Add alembic to your plugins list in ~/.zshrc:

    plugins=(... alembic)
    
  3. Reload your shell:

    source ~/.zshrc
    

Manual Installation

  1. Download alembic.plugin.zsh
  2. Place it in ~/.oh-my-zsh/custom/plugins/alembic/
  3. Follow steps 2-3 above

Usage

Aliases

AliasCommandDescription
alcalembic currentShow current revision
alhalembic headsShow available heads
alhistalembic historyShow revision history
alshowalembic showShow specific revision
alupalembic upgradeUpgrade to revision
aldownalembic downgradeDowngrade to revision
alrevalembic revisionCreate new revision
albralembic branchesShow branch points
alcheckalembic checkCheck for pending upgrades
alstampalembic stampStamp revision table
almergealembic mergeMerge revisions
aleditalembic editEdit revision file

Helper Functions

  • alup-head - Upgrade to head revision
  • alrev-m "message" - Create revision with message
  • alrev-auto "message" - Create auto-generated revision with message
  • aldown-1 - Downgrade by one revision
  • alhist-v - Show verbose history
  • alembic-status - Show comprehensive status overview
  • alembic-init [directory] - Initialize Alembic with helpful reminders

Tab Completion

The plugin provides intelligent tab completion for:

  • All Alembic commands
  • Command-specific options and flags
  • File paths for configuration files
  • Revision identifiers where applicable

Examples

# Quick status check
alembic-status

# Create a new migration
alrev-auto "add user table"

# Upgrade to latest
alup-head

# Check what's pending
alcheck

# View recent history
alhist-v

# Downgrade one step
aldown-1

Requirements

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Alembic - The database migration tool
  • oh-my-zsh - Framework for managing Zsh configuration
  • The Zsh completion system documentation

Note: This plugin is not officially affiliated with Alembic or SQLAlchemy.

Authors