Simple database migration tool inspired by knex.js
.
Migrations are by default applied in order of timestamp inside migrations
directory
pip install https://github.com/vane/asyncpg-migrate/archive/0.0.1.tar.gz
asyncpg-migrate -h
asyncpg-migrate -a 'test migration'
migration will be added to migrations/${timestamp}_test_migration.py with following template
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import asyncpg
async def up(config):
conn: asyncpg.Connection = await asyncpg.connect(**config)
pass
async def down(config):
conn: asyncpg.Connection = await asyncpg.connect(**config)
pass
asyncpg-migrate -l
asyncpg-migrate -m
asyncpg-migrate -m migrations/migration_file.py
asyncpg-migrate -r migrations/migration_file.py
asyncpg-migrate -c conf/some.config.yaml
example config
db:
host: 127.0.0.1
port: 5432
user: postgres
password: postgres
database: asyncpg-migate-test
asyncpg-migrate -d /opt/my-migrations
PG_USER
PG_PASSWORD
PG_DBNAME
PG_HOST
PG_PORT