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 and Flask-Script:

$ ./manage.py db revision "making changes"
$ ./manage.py db upgrade

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

Uploaded Source

Built Distribution

Flask_Alembic-1.2.1-py2.py3-none-any.whl (9.3 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for Flask-Alembic-1.2.1.tar.gz
Algorithm Hash digest
SHA256 28f2df9fa7220c3e07b4fa314a244bca6e084ca3aadafdda1f171a619115f503
MD5 0d34e04b19806c2f68b8397ff0b6aef4
BLAKE2b-256 4e7e32a50e6c4378c06184c522be7ba503391a8963b40c237e37e561883c1c3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Flask_Alembic-1.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fea5cfdacea519ed45dfb0e239016f019bf95aea99463e330440e9d41b245f46
MD5 bcd357c98568161e074081c192ccc09a
BLAKE2b-256 b050f883e1a1230d1e4143349bae40da6144b02e5eef637ea6a5c12f1132208c

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