Registry / database / aerich

aerich

JSON →
library0.9.2pypypi✓ verified 82d ago

Aerich is a database migrations tool specifically designed for Tortoise ORM. It automates schema evolution by generating and applying migration scripts, making it easier to manage database changes in Python projects. It is actively maintained, with version 0.9.2 being the latest as of early 2024, and features regular releases for bug fixes and new functionality.

pip install aerich
INSTALL
IMPORT
SIG · AERICH
A
aerich
databasepythonv0.9.2
Install
2.6s avg
Import
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 26.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.6s · import 0.000s · 27MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Aerich
from aerich import Aerich
from aerich.commands import AerichCommand
Command
from aerich import Command
Migrate
from aerich import Migrate

This quickstart provides the content for a `config.py` file, defining a simple Tortoise-ORM configuration (`TORTOISE_CONFIG`) and a `User` model. To use Aerich: 1. Save the above content as `config.py` in your project root. 2. Run the following commands in your terminal to initialize Aerich, create, and apply migrations: ```bash aerich init -t config.TORTOISE_CONFIG aerich migrate aerich upgrade ```

# config.py from tortoise import fields, models class User(models.Model): id = fields.IntField(pk=True) name = fields.CharField(max_length=255) class Meta: table = "users" TORTOISE_CONFIG = { "connections": {"default": "sqlite://db.sqlite3"}, "apps": { "models": { "models": ["config", "aerich.models"], # "config" refers to models defined in this file "default_connection": "default", } }, }
aerich --version
Debug
Known issues
breakingAerich versions 0.6.0 and later removed the `AERICH_CONFIG` environment variable and changed how Tortoise-ORM configuration is specified.
fix
Always use the `-t` or `--tortoise-config` command-line argument to specify your Tortoise-ORM configuration module and variable name, e.g., `aerich init -t my_app.config.TORTOISE_CONFIG`.
affects: >=0.6.0
gotchaFailing to include `aerich.models` in your `TORTOISE_CONFIG['apps']['models']['models']` list will prevent Aerich from managing its internal schema and lead to errors.
fix
Ensure your `TORTOISE_CONFIG['apps']['models']['models']` list includes `'aerich.models'`, for example: `"models": ["your_app.models", "aerich.models"]`.
affects: All
gotchaUsing `sqlite://:memory:` in your `TORTOISE_CONFIG` for database connections will result in database changes (including migrations) not being persisted.
fix
For persistent migrations, always configure a file-based SQLite database (e.g., `sqlite://db.sqlite3`) or a connection to a persistent database server.
affects: All
Upgrade
Version history
0.9.2latest on PyPI · released Oct 10, 2025
Audit
Dependencies
tortoise-ormrequiredAerich is a migration tool exclusively for Tortoise ORM.
Agent activity
52 hits · last 30 days
node
48
OpenAI (training)
1
Resources
aerich — pip install aerich · libregistry