itinerary
A tool to apply pure SQL migrations to PostgreSQL databases at runtime.
Itinerary uses PostgreSQL’s advisory locks feature to prevent multiple instances from running migrations simultaneously. As such, it’s suitable for use in horizontally scalable applications.
Installation
pip install itinerary
Usage
Put raw SQL files in your migration directory, e.g.:
migrations/0001_create_table.sql
migrations/0002_add_column.sql
migrations/0003_create_index.sql
Then run the auto_migrate function before your application starts.
Flask example
import itinerary
from flask import Flask
app = Flask(__name__)
if __name__ == '__main__':
conn = psycopg2.connect(host='localhost')
itinerary.auto_migrate(conn)
app.run()
uWSGI example
import itinerary
from uwsgidecorators import postfork
@postfork
def migrate_db():
conn = psycopg2.connect(host='localhost')
itinerary.auto_migrate(conn)
Configuration
itinerary.auto_migrate(connection, path='migrations',
version_table='_version', lock_id=0)
- path – Directory to scan for migration files.
- version_table – Table to use to keep track of applied migrations. If it doesn’t exist, itinerary will create it.
- lock_id – The key to use when acquiring and releasing a PostgreSQL advisory lock.
Metadata
Release files for itinerary 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| itinerary-1.0.1.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| itinerary-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / itinerary-1.0.1.tar.gz
| Download URL | itinerary-1.0.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38028382f7ccdbe56d1914272fd29b9c3906d2fe629750fc382d9d8359555ce4
|
|
BLAKE2b-256 checksum How to use checksums |
0de2cfb7d7208223dfb1e0f5ae8b0b7a38e5284c4cc6f90a833ca8431285a12e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|
Release files / itinerary-1.0.1-py3-none-any.whl
| Download URL | itinerary-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2643f4042832f9e060298a24ad0654138bf1ec97b3042da206d1594b53ab4562
|
|
BLAKE2b-256 checksum How to use checksums |
99731333cb3e4117a0fa29b10fe952c3f8ade29b271210aa3a2397a5bd6e90e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1
|