Skip to main content

Miggy

CI workflow PyPi Version

A database migration engine for Peewee, inspired by the architecture of Django migrations.

Miggy builds a state from your migrations and automatically generates a diff against the current model state to create a migration.

Miggy supports detecting changes to most Peewee classes used to define a table, including fields, indexes, primary keys, DEFAULT and CHECK constraints.

New to Miggy?

Installation

pip install miggy

Why Fork?

Since the original project has not been actively maintained for some time, this project started as a fork of the original peewee_migrate by klen — many thanks to them for the initial work!

Since the fork, the project has been significantly reworked. The architecture has been almost completely redesigned, numerous bugs have been fixed, and support for many Peewee schema features has been added.

Usage

From shell

Getting help:

$ miggy --help

Usage: miggy [OPTIONS] COMMAND [ARGS]...

Options:
    --config PATH  Path to the config file. Defaults to miggyconf.py in the
                    current directory.  [env var: MIGGY_CONFIG]
    --help         Show this message and exit.

Commands:
    init            Create a default configuration file.
    list            List migrations.
    makemigrations  Create a migration automatically
    migrate         Migrate database.
    rollback        Rollback a migration with given name or number of last...
    squash          Squash migrations into one.

From python

from miggy import Router
from peewee import SqliteDatabase

router = Router(SqliteDatabase('test.db'))

# Create migration
router.create('migration_name')

# Run migration/migrations
router.run('migration_name')

# Run all unapplied migrations
router.run()

Migration files

By default, migration files are looked up in the migrations directory next to the config file, but a custom directory can be given with the MIGRATE_DIR setting.

Migration files are sorted and applied in ascending order per their filename.

Each migration file specifies a Migration class with forward and backward lists of operations to apply when migrating forwards and rolling back:

import peewee as pw
from miggy import operations

class Migration(operations.Migration):
    atomic = True

    forward = [
        operations.AddField(
            model_name='user',
            name='age',
            field=pw.IntegerField(null=True),
        ),
    ]

    backward = [
        operations.RemoveField(
            model_name='user',
            name='age',
        ),
    ]

Developing

Install dependencies using pip:

pip install -e .[dev]

Run databases:

docker-compose up -d

Run checks and tests:

poe check

License

Licensed under a BSD license.

Metadata

Release files for miggy 2.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miggy 2.6.1
File Size Uploaded Provenance Actions
miggy-2.6.1.tar.gz 30.8 kB Without provenance Details for miggy-2.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for miggy 2.6.1
File Interpreter ABI Platform Actions
miggy-2.6.1-py3-none-any.whl Python 3 none any Details for miggy-2.6.1-py3-none-any.whl

Total release size: 67.3 kB

Release files / miggy-2.6.1.tar.gz

Download URL miggy-2.6.1.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a12b636719e2d17f6d3378f7c8eda0c8447eba8524be098dcfd4c48800f2c8f5
BLAKE2b-256 checksum
How to use checksums
1ead08d1a410b0718a172abc840f159f15e21a8859336316037619cd354b2896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / miggy-2.6.1-py3-none-any.whl

Download URL miggy-2.6.1-py3-none-any.whl
Size 36.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a9b500b75cc1275a3402af4141f38cf4819f06f14a5bea099bc297e41b3e529
BLAKE2b-256 checksum
How to use checksums
62dd89c8fcd1f8c03185cfb2030b7d36807ed2a64052fcc2b5f139d7bc5c54a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for miggy 2.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page