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.

Full documentation

Installation

Install releases from PyPI:

pip install Flask-Alembic

Install the latest code from BitBucket:

pip install https://bitbucket.org/davidism/flask-alembic/get/default.tar.gz

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

Commands are included for Click (Flask 0.11, or Flask-CLI):

$ flask db revision "making changes"
$ flask db upgrade

and Flask-Script:

$ python manage.py db --help

Differences from Alembic core

  • Configuration is taken from Flask.config 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 or multiple databases.

  • Adds a system for managing independent migration branches and makes it easier to work with named branches.

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.

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-2.0.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

Flask_Alembic-2.0.0-py2.py3-none-any.whl (10.6 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for Flask-Alembic-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1ccbca096bbb64ae2c76547164f6fd174f46d3b861c9a081d06593b2476010fe
MD5 00814db38c023d8af97d2584accd1d6d
BLAKE2b-256 652b02722e01ea6739cf31c5ff01c41a9353050aba1becaaef4e712ffae8acd3

See more details on using hashes here.

File details

Details for the file Flask_Alembic-2.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_Alembic-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1d377ad8ba144f34c369f54706b67c9f927527cf39bf918c16ca0a99ce045dfe
MD5 b5a312d694cc230d125df38c4fc349fd
BLAKE2b-256 b1deebe0b3d6f89d923253c89c056f39ccf90c36914343959ce6dd44112103e9

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