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:
create Create a migration.
init Create a default configuration file.
list List migrations.
makemigrations Create a migration automatically
merge Merge migrations into one.
migrate Migrate database.
rollback Rollback a migration with given name or number of last...
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 config_path/migrations
directory, but custom directory can be given.
Migration files are sorted and applied in ascending order per their filename.
Each migration file must specify migrate() function and may specify
rollback() function:
def migrate(migrator, database, fake=False, **kwargs):
pass
def rollback(migrator, database, fake=False, **kwargs):
pass
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.5.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 | |
|---|---|---|---|
| miggy-2.5.0.tar.gz | 27.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| miggy-2.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.8 kB
Release files / miggy-2.5.0.tar.gz
| Download URL | miggy-2.5.0.tar.gz |
|---|---|
| Size | 27.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5372cedec4339f2fe431937dab83b8f3a1e9a6ba0bea8d082f8f388098e84c57
|
|
BLAKE2b-256 checksum How to use checksums |
2cee0fc189e5b969e7845c37f1e0431bfd0c85e471b7d3621f79e3b2bd4f9089
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","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.5.0-py3-none-any.whl
| Download URL | miggy-2.5.0-py3-none-any.whl |
|---|---|
| Size | 35.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
327aecfe31e16fbae4f00c24645a2904a92dd327cd61e9722fea3b9bf391993b
|
|
BLAKE2b-256 checksum How to use checksums |
88e4fb08f1f5efaa0f7d6770f0d55bd63511e3eb572ba01c83cd2a066acb9a94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","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}
|