a database migration tool for usage with the peewee ORM
Project description
Miggy
A simple migration engine for peewee.
Why Fork?
This project is a fork of the original https://github.com/klen/peewee_migrate by klen — many thanks to them for the initial work!
Since the original project has not been actively maintained for some time, this fork was created to fix critical issues and continue development.
Requirements
- python >= 3.10
- peewee>=3.17.9
Installation
pip install miggy
Documentation
Usage
From shell
Getting help:
$ miggy --help
Usage: miggy [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
create Create migration.
migrate Run migrations.
rollback Rollback migration.
Create migration:
$ miggy create --help
Usage: miggy create [OPTIONS] NAME
Create migration.
Options:
--auto FLAG Scan sources and create db migrations automatically. Supports autodiscovery.
--auto-source TEXT Set to python module path for changes autoscan (e.g. 'package.models'). Current directory will be recursively scanned by default.
--database TEXT Database connection
--directory TEXT Directory where migrations are stored
--schema TEXT Database schema
-v, --verbose
--help Show this message and exit.
Run migrations:
$ miggy migrate --help
Usage: miggy migrate [OPTIONS]
Run migrations.
Options:
--name TEXT Select migration
--database TEXT Database connection
--directory TEXT Directory where migrations are stored
--schema TEXT Database schema
-v, --verbose
--help Show this message and exit.
Auto create migration:
$ miggy makemigrations --help
Usage: miggy makemigrations [OPTIONS]
Create a migration automatically
Similar to `create` command, but `auto` is True by default, and `name` not
required
Options:
--name TEXT Migration file name. By default will be
'auto_YYYYmmdd_HHMM'
--auto Scan sources and create db migrations automatically.
Supports autodiscovery.
--auto-source TEXT Set to python module path for changes autoscan (e.g.
'package.models'). Current directory will be recursively
scanned by default.
--database TEXT Database connection
--directory TEXT Directory where migrations are stored
--schema TEXT Database schema
-v, --verbose
--help Show this message and exit.
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 os.getcwd()/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
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/kalombos/miggy/issues
Developing
Install dependencies using pip:
pip install -e .[dev]
Run databases:
docker-compose up -d
Run checks and tests:
poe check
Contributors
See AUTHORS.md
License
Licensed under a BSD license.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file miggy-2.1.1.tar.gz.
File metadata
- Download URL: miggy-2.1.1.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e7e172579b5db1df4d819c671d47895b32bc46ee1deedf5ed70694eac2dd24f
|
|
| MD5 |
5adee76da014481c7118e52c29738254
|
|
| BLAKE2b-256 |
4f07b6fdfaf184f3769be134eeecb1c54926e36d8fd9165217c4c116b1c77e84
|
File details
Details for the file miggy-2.1.1-py3-none-any.whl.
File metadata
- Download URL: miggy-2.1.1-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f03ab05cbb2bdc4c9c44da5ce4493f52446e30f2bb25763d78ad5593268de93
|
|
| MD5 |
95a6e64c92e1e541021e9a8bb9007d21
|
|
| BLAKE2b-256 |
9e3c7cf22fcaea112efb46d8839c581320f6ece60646e5f91a53f511f9e299ad
|