Skip to main content

Lightweight and extensible Python library for managing database migrations

Project description

Python versions Test

🛠️ Migropy

Migropy is a lightweight and extensible Python library for managing database migrations.
Designed for simplicity and flexibility, it helps teams apply, track, and version-control schema changes across multiple environments.


🚀 Features

  • ✅ Versioned migrations with up/down support
  • ✅ Compatible with PostgreSQL & MySQL
  • ✅ CLI for common migration operations
  • ✅ Safe and idempotent execution
  • ✅ Customizable migration directory structure

📦 Installation

pip install migropy

📖 How to use

1. Initialize a new migration project

migropy init

2. Go to the migrations directory

cd migrations

3. Fill the config.ini file

[database]
host = localhost
port = 5432
user = postgres
password = postgres
dbname = my_database
type = postgres # or mysql

[logger]
level = DEBUG

4. Create a new migration

migropy generate 'migration name'

5. Apply the migrations

migropy upgrade

📄 Migration example

-- Up migration
CREATE TABLE users
(
    id    SERIAL PRIMARY KEY,
    name  VARCHAR(100) NOT NULL,
    email VARCHAR(100) NOT NULL
);

-- Down migration
DROP TABLE users;

⚙️ Available commands

Comando Descrizione
migropy init Init migratron environment
migropy generate <name> Generate a new sql migration
migropy upgrade Apply all the migration
migropy downgrade Rollback all revisions
migropy list Show current migration status

🧪 Running Unit Tests

To run the unit tests using poetry, you can use the following command:

poetry run pytest --rootdir=tests

📝 Changelog

See the full CHANGELOG.md

Latest Changes

  • 0.2.1 – Increase minimum python version to 3.10 & refactor MigrationEngine
  • 0.2.0 – MySQL database support
  • 0.1.1 – Initial project setup with PostgreSQL

📄 License

MIT License © 2025 — teoxy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

migropy-0.2.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

migropy-0.2.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file migropy-0.2.1.tar.gz.

File metadata

  • Download URL: migropy-0.2.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for migropy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 aac5473013756320deb86f7b636d78e7cf97d51ea57f6ce6e1595a7b9b3612d3
MD5 2651e927449f4121d0dbfaf89e628e6c
BLAKE2b-256 5a659208d3d892bb41b881f10a94d017eaf59d905cbf8597c24ed8dba8e3c13f

See more details on using hashes here.

File details

Details for the file migropy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: migropy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for migropy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53c090e042cf8fa33a9bdc38e600bbaa5a3d3b88db1b3ca2e11f62171b963edb
MD5 55dfcc6ac3e692b9c0ab98c026ddb2c0
BLAKE2b-256 1f8665f991863aa38d12a6ee149800b20d2871ff61c14db2d043457141eabaec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page