Skip to main content

Alembic is a new database migrations tool, written by the author of SQLAlchemy. A migrations tool offers the following functionality:

  • Can emit ALTER statements to a database in order to change the structure of tables and other constructs

  • Provides a system whereby “migration scripts” may be constructed; each script indicates a particular series of steps that can “upgrade” a target database to a new version, and optionally a series of steps that can “downgrade” similarly, doing the same steps in reverse.

  • Allows the scripts to execute in some sequential manner.

The goals of Alembic are:

  • Very open ended and transparent configuration and operation. A new Alembic environment is generated from a set of templates which is selected among a set of options when setup first occurs. The templates then deposit a series of scripts that define fully how database connectivity is established and how migration scripts are invoked; the migration scripts themselves are generated from a template within that series of scripts. The scripts can then be further customized to define exactly how databases will be interacted with and what structure new migration files should take.

  • Full support for transactional DDL. The default scripts ensure that all migrations occur within a transaction - for those databases which support this (Postgresql, Microsoft SQL Server), migrations can be tested with no need to manually undo changes upon failure.

  • Minimalist script construction. Basic operations like renaming tables/columns, adding/removing columns, changing column attributes can be performed through one line commands like alter_column(), rename_table(), add_constraint(). There is no need to recreate full SQLAlchemy Table structures for simple operations like these - the functions themselves generate minimalist schema structures behind the scenes to achieve the given DDL sequence.

  • “auto generation” of migrations. While real world migrations are far more complex than what can be automatically determined, Alembic can still eliminate the initial grunt work in generating new migration directives from an altered schema. The --autogenerate feature will inspect the current status of a database using SQLAlchemy’s schema inspection capabilities, compare it to the current state of the database model as specified in Python, and generate a series of “candidate” migrations, rendering them into a new migration script as Python directives. The developer then edits the new file, adding additional directives and data migrations as needed, to produce a finished migration. Table and column level changes can be detected, with constraints and indexes to follow as well.

  • Full support for migrations generated as SQL scripts. Those of us who work in corporate environments know that direct access to DDL commands on a production database is a rare privilege, and DBAs want textual SQL scripts. Alembic’s usage model and commands are oriented towards being able to run a series of migrations into a textual output file as easily as it runs them directly to a database. Care must be taken in this mode to not invoke other operations that rely upon in-memory SELECTs of rows - Alembic tries to provide helper constructs like bulk_insert() to help with data-oriented operations that are compatible with script-based DDL.

  • Non-linear versioning. Scripts are given UUID identifiers similarly to a DVCS, and the linkage of one script to the next is achieved via markers within the scripts themselves. Through this open-ended mechanism, branches containing other migration scripts can be merged - the linkages can be manually edited within the script files to create the new sequence.

  • Provide a library of ALTER constructs that can be used by any SQLAlchemy application. The DDL constructs build upon SQLAlchemy’s own DDLElement base and can be used standalone by any application or script.

  • Don’t break our necks over SQLite’s inability to ALTER things. SQLite has almost no support for table or column alteration, and this is likely intentional. Alembic’s design is kept simple by not contorting its core API around these limitations, understanding that SQLite is simply not intended to support schema changes. While Alembic’s architecture can support SQLite’s workarounds, and we will support these features provided someone takes the initiative to implement and test, until the SQLite developers decide to provide a fully working version of ALTER, it’s still vastly preferable to use Alembic, or any migrations tool, with databases that are designed to work under the assumption of in-place schema migrations taking place.

Documentation and status of Alembic is at http://readthedocs.org/docs/alembic/.

Metadata

Release files for uliweb-alembic 0.6.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uliweb-alembic 0.6.9
File Size Uploaded Provenance
uliweb-alembic-0.6.9.tar.gz 480.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for uliweb-alembic 0.6.9
File Interpreter ABI Platform
uliweb_alembic-0.6.9-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 780.5 kB

Release files / uliweb-alembic-0.6.9.tar.gz

Download URL uliweb-alembic-0.6.9.tar.gz
Size 480.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f8044301d6252dac2a509d5dcee515255b986d7496e916fbb21632c8a1749ef0
BLAKE2b-256 checksum
How to use checksums
a8e44cdee9e8ac5e0d4ed9d190f59eb7f4f359fa0d4244472fa1a3cc31f7edc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / uliweb_alembic-0.6.9-py2.py3-none-any.whl

Download URL uliweb_alembic-0.6.9-py2.py3-none-any.whl
Size 299.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f81c8570548e4d36d85120838951f8936125d22b34df40d5ad90967441dd9599
BLAKE2b-256 checksum
How to use checksums
ef31da67d80b67d067977a0244019995f3d0e90570baac79483855d51f1c069f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for uliweb-alembic 0.6.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page