Migratore Infra-structure
Project description
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 migrationPORT- TCP port to be used in the connection with the database systemUNIX_SOCKET- Filesystem path to the UNIX socket file to be used in connectionDB- Name of the database used as the migration targetUSERNAME- Username for authentication in the databasePASSWORD- Password to be used for authentication in the databaseFS- Base file system path for file migration (may depend on migration context)DB_URL- The database connection URL following the formatprotocol://username:password@host:port/dbSAFE- If the migration operation should be performed in a safe manner.
Commands
help- Prints a help message about the CLI interfaceversion- Prints the current version of migratoreenviron- Displays the current environment in the standard outputlist- Lists the executed migrations on the current databaseerrors- Lists the various errors from migration of the databasemark [path]- Marks all pending migrations as applied using the defined directory or currenttrace [id]- Prints the traceback for the error execution with the provided idrebuild [id]- Run the partial execution of the migration with the given idtouch [id]- Touches a migration file updating its timestamp to the current timesquash [start] [end] <output>- Combines multiple migrations into a single fileupgrade [path]- Executes the pending migrations using the defined directory or currentdry_upgrade [path]- Prints the pending migrations without executing themdowngrade [path]- Rolls back the last applied migration using the defined directory or currentdry_downgrade [path]- Prints the last applied migration without rolling it backskip [path]- Skips the current migration (next to be run) using the defined directory or currentgenerate [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 throughupgrade. InvokesMigration.run.Run Partial- Re-execution of a single migration throughrebuild [id]. InvokesMigration.run_partial, useful for resuming a migration that previously failed mid-way.Run Skip- Records the migration as applied throughskipwithout executing itsrunbody. InvokesMigration.run_skip. Handy when adoptingmigratoreon a database that already has the target schema, or when a migration has been applied out-of-band.Rollback- Explicit downgrade throughdowngrade, or recovery rollback automatically triggered when arunfails (whenSAFEisFalse). InvokesMigration.rollback. Theforceargument distinguishes the two cases:Truefor an explicit downgrade,Falsefor 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.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file migratore-0.10.0.tar.gz.
File metadata
- Download URL: migratore-0.10.0.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ec18392c15531c30b6a36174d6fb28232572abe63aece42439d38eab8c00e33
|
|
| MD5 |
af3d335e08d6c015ffa8dfcd2e081234
|
|
| BLAKE2b-256 |
ac849a533fcc868e656aac49b3c9b7b82367ec2b29bf9d406b9e2ed0d151c9d1
|
File details
Details for the file migratore-0.10.0-py2.py3-none-any.whl.
File metadata
- Download URL: migratore-0.10.0-py2.py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16f43325bbd4bdad371bfff2bb2c8d69274c5e51a14b54fab106fa8685caff25
|
|
| MD5 |
b93b5cdf17cce8a49df02f7df576f5c0
|
|
| BLAKE2b-256 |
c9ca98cb0be43c9237d2d88e13aee825978a8fe7472a2fff2e54c9aa6b3c4913
|