Miggy
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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| miggy-2.6.0.tar.gz | 30.6 kB | Without provenance | Details for miggy-2.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| miggy-2.6.0-py3-none-any.whl | Python 3 | none | any | Details for miggy-2.6.0-py3-none-any.whl |
Total release size: 66.7 kB
Release files / miggy-2.6.0.tar.gz
| Download URL | miggy-2.6.0.tar.gz |
|---|---|
| Size | 30.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1703555c38176a9f082ff361bb9ea78457df24d9647c742ad735f2c3543b21dd
|
|
BLAKE2b-256 checksum How to use checksums |
2e13df68af389c1013c85b13dcea6d9670368441713656773e0de99b7ae577a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.0-py3-none-any.whl
| Download URL | miggy-2.6.0-py3-none-any.whl |
|---|---|
| Size | 36.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e77c7813c447a621da4b5faa290dd49ccda54c604f1c528aceeb5c1753c43f4b
|
|
BLAKE2b-256 checksum How to use checksums |
82e45ebcf61badc31283bc31d515b1ecb4a44c35fbce7bcc1b541b144c74c84c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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.0
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.