Skip to main content

Migratore

Simple migration framework / infra-structure for SQL-based databases.

Installation

pip install migratore

Execution

HOST=${HOST} DB=${DB_NAME} USERNAME=${DB_USER} PASSWORD=${DB_PASS} migratore upgrade

Variables

  • HOST - Hostname or IP address of the database system for migration
  • PORT - TCP port to be used in the connection with the database system
  • UNIX_SOCKET - Filesystem path to the UNIX socket file to be used in connection
  • DB - Name of the database used as the migration target
  • USERNAME - Username for authentication in the database
  • PASSWORD - Password to be used for authentication in the database
  • FS - Base file system path for file migration (may depend on migration context)
  • DB_URL - The database connection URL following the format protocol://username:password@host:port/db
  • SAFE - If the migration operation should be performed in a safe manner.

Commands

  • help - Prints a help message about the CLI interface
  • version - Prints the current version of migratore
  • environ - Displays the current environment in the standard output
  • list - Lists the executed migrations on the current database
  • errors - Lists the various errors from migration of the database
  • mark [path] - Marks all pending migrations as applied using the defined directory or current
  • trace [id] - Prints the traceback for the error execution with the provided id
  • rebuild [id] - Run the partial execution of the migration with the given id
  • touch [id] - Touches a migration file updating its timestamp to the current time
  • squash [start] [end] <output> - Combines multiple migrations into a single file
  • upgrade [path] - Executes the pending migrations using the defined directory or current
  • dry_upgrade [path] - Prints the pending migrations without executing them
  • downgrade [path] - Rolls back the last applied migration using the defined directory or current
  • dry_downgrade [path] - Prints the last applied migration without rolling it back
  • skip [path] - Skips the current migration (next to be run) using the defined directory or current
  • generate [path] - Generates a new migration file into the target path

Operations

Every command that touches a migration records a row in the migratore bookkeeping table with an operation value that describes what was done. The same migration can have multiple rows over time (e.g. a Run followed later by a Rollback). The most recent row for each UUID is what determines whether the migration is currently applied.

  • Run - Normal application of a migration through upgrade. Invokes Migration.run.
  • Run Partial - Re-execution of a single migration through rebuild [id]. Invokes Migration.run_partial, useful for resuming a migration that previously failed mid-way.
  • Run Skip - Records the migration as applied through skip without executing its run body. Invokes Migration.run_skip. Handy when adopting migratore on a database that already has the target schema, or when a migration has been applied out-of-band.
  • Rollback - Explicit downgrade through downgrade, or recovery rollback automatically triggered when a run fails (when SAFE is False). Invokes Migration.rollback. The force argument distinguishes the two cases: True for an explicit downgrade, False for recovery.

A migration is considered currently applied whenever the most recent successful row for its UUID is anything other than Rollback. This means a migration that was rolled back via downgrade becomes pending again and will be re-applied by the next upgrade.

A migration operation that fails is recorded with an error result, and the command that started it (upgrade, mark, skip, rebuild or downgrade) stops on it without going through the migrations that follow and raises an error, so that the command exits with a non-zero code. A migration whose run fails stays pending and is retried by the next upgrade.

Examples

database = Migratore.get_database()
table = database.get_table("users")
table.add_column("username", type = "text")

License

Migratore is currently licensed under the Apache License, Version 2.0.

Build Automation

Build Status Coverage Status PyPi Status License

Metadata

Release files for migratore 0.12.0

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

Source distribution (sdist)

Source distribution for migratore 0.12.0
File Size Uploaded Provenance Actions
migratore-0.12.0.tar.gz 21.2 kB Without provenance Details for migratore-0.12.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for migratore 0.12.0
File Interpreter ABI Platform Actions
migratore-0.12.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for migratore-0.12.0-py2.py3-none-any.whl

Total release size: 44.2 kB

Release files / migratore-0.12.0.tar.gz

Download URL migratore-0.12.0.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ee0b68385d3bb0c783166e27eb20fe8f77698cfe70b7197e66c70a2d99c19cd4
BLAKE2b-256 checksum
How to use checksums
db630dcdb497c0b5a27bf92bd54c5c36d1084a737eb7224008ae9323de1811ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Release files / migratore-0.12.0-py2.py3-none-any.whl

Download URL migratore-0.12.0-py2.py3-none-any.whl
Size 23.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
156d34481cae4c2f3c829dcc5d851a91a236cd0d7b831d735b3bd39460e9f0bb
BLAKE2b-256 checksum
How to use checksums
ff48ba9f175dafc56e0e9e302e0e5dcbc45d51f0a592acf0f823c99a0c137cab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Security for migratore 0.12.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.12.0 This release

2 release files No provenance

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