pg_sqlapply // tool

MIT License · Open Source

PostgreSQL migration tool for humans

Changesets, dry-run, transaction control, execution history with MD5 checksums. Written in Python, works on Linux.

~/project
# clone & init
$ git clone https://github.com/mk-samoilov/pg_sqlapply.git
$ cd pg_sqlapply
$ python3 -m sqlapply

# create changeset
$ mkdir -p changes/v1/my_db
$ vi changes/v1/my_db/01_schema.sql

# check & execute
$ python3 -m sqlapply v1 --init
$ python3 -m sqlapply v1 --check
$ python3 -m sqlapply v1

Features

Organized Structure
Changesets with database sections and numbered SQL scripts
Transaction Control
Single transaction mode with automatic rollback on errors
Execution History
Tracks executed scripts with MD5 checksums in database
Dry Run
Check and validate changesets before actual execution
Force Re-apply
Re-execute all, failed only, or changed scripts by MD5
Two Editions
Full Python package or single-file .py distribution

Download

Edition Repository Archive
Package github.com .zip
Onefile

Requirements

Python 3.10+
PostgreSQL + psql
Linux