Skip to main content

Flask extension to integrate Alembic migrations

Project description

This Flask extension provides a configurable Alembic migration environment around a Flask-SQLAlchemy database.

Installation

Install releases from PyPI:

pip install Flask-Alembic

Install latest code from BitBucket:

pip install https://bitbucket.org/davidism/flask-alembic

Basic Usage

You’ve created a Flask application and some models with Flask-SQLAlchemy. Now start using Flask-Alembic:

from flask_alembic import Alembic

# Intialize the extension
alembic = Alembic()
alembic.init_app(app)

# Auto-generate a migration
alembic.revision('making changes')

# Upgrade the database
alembic.upgrade()

# Access the internals
environment_context = alembic.env

Differences from Alembic core

  • Configuration is taken from Flask instead of alembic.ini.

  • The migrations are stored directly in the migrations folder instead of the versions folder.

  • The extension provides the migration environment instead of env.py.

  • Does not (currently) support offline migrations.

Differences from Flask-Migrate

Flask-Migrate is a simple wrapper around the existing Alembic commands. It associates the Flask-SQLAlchemy database with Alembic, and wraps the Alembic commands with Flask-Script. It still requires the standard Alembic file structure, does not integrate with Flask configuration, and does not expose the Alembic internals.

TODO

  • See if db.session can be used rather than establishing new connections.

  • Support multiple databases though Flask-SQLAlchemy’s binds.

  • Support offline migrations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-Alembic-1.0.2.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file Flask-Alembic-1.0.2.tar.gz.

File metadata

File hashes

Hashes for Flask-Alembic-1.0.2.tar.gz
Algorithm Hash digest
SHA256 401d75647f901016b26a440d31ac894006d619080f57885e0811d6e83adb7c43
MD5 9f65aa13e5eefd621a75d5fc14ac7e02
BLAKE2b-256 5649ab4ab55a8409406c056e7c750f358041086a7fe7adc9eb220861613067de

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page