A tool to apply pure SQL migrations to PostgreSQL databases at runtime.
Project description
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.
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
itinerary-1.0.0.post0.tar.gz
(3.1 kB
view details)
Built Distribution
File details
Details for the file itinerary-1.0.0.post0.tar.gz
.
File metadata
- Download URL: itinerary-1.0.0.post0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03e02d940ed573e91cc1835239594af2ff71583450f8142af01d631e7eb39bf3 |
|
MD5 | 85ec08acccb9a0901c08a28734c58499 |
|
BLAKE2b-256 | f555110c29336e1402ca10e404eb424364028684fb03536c3356ff5dd0724b41 |
File details
Details for the file itinerary-1.0.0.post0-py3-none-any.whl
.
File metadata
- Download URL: itinerary-1.0.0.post0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5a28346adbb5a8c655beae3e8b1f60bdebff5e8a1c0d97ab089a072db59d4b7 |
|
MD5 | ce712487839f45993163ceee7eccc74b |
|
BLAKE2b-256 | 7c6fd7ae34e883c1933649e7da2420efeb20f413b4684af0d1e74a427fb2a041 |