Skip to main content

Tortoise Pathway

⚠️ This project is in development and some things might break. ⚠️ Only Postgres and Sqlite are supported for now.

🤓 Code contributions and assistance with testing are welcome and appreciated!

Tortoise Pathway is a migration system for Tortoise ORM, inspired by Django's migration approach.

See CHANGELOG.md for the latest changes.

Features

  • Generate schema migrations from Tortoise models
  • Apply and revert migrations
  • No need for a database connection to generate migrations
  • If you have used Django migrations, you will feel at home

Installation

You can install the package using pip:

pip install tortoise-pathway

Or if you prefer using uv:

uv add tortoise-pathway

Development

Running tests:

uv run pytest

Usage

Configuration

Create a configuration module with a TORTOISE_ORM dictionary. For example, in config.py:

TORTOISE_ORM = {
    "connections": {
        "default": {
            "engine": "tortoise.backends.sqlite",
            "credentials": {
                "file_path": "db.sqlite3",
            },
        },
    },
    "apps": {
        "models": {
            "models": ["myapp.models"],
            "default_connection": "default",
        },
    },
}

Defining Models

Define your Tortoise ORM models as usual:

# myapp/models.py
from tortoise import fields, models

class User(models.Model):
    id = fields.IntField(primary_key=True)
    name = fields.CharField(max_length=255)
    email = fields.CharField(max_length=255, unique=True)
    created_at = fields.DatetimeField(auto_now_add=True)

Working with Migrations

Generate migrations automatically based on model changes:

python -m tortoise_pathway --config myapp.config.TORTOISE_ORM make

or generate an empty migration with a name:

python -m tortoise_pathway --config myapp.config.TORTOISE_ORM make --empty --name "add_email_field"

Apply migrations:

python -m tortoise_pathway --config myapp.config.TORTOISE_ORM migrate

Revert a migration:

python -m tortoise_pathway --config myapp.config.TORTOISE_ORM rollback --migration <migration_name>

Metadata

Release files for tortoise-pathway 0.2.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 tortoise-pathway 0.2.1
File Size Uploaded
tortoise_pathway-0.2.1.tar.gz 35.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tortoise-pathway 0.2.1
File Interpreter ABI Platform
tortoise_pathway-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 78.3 kB

Release files / tortoise_pathway-0.2.1.tar.gz

Download URL tortoise_pathway-0.2.1.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f3c8fa548975c19a4d6157f0dc5372782afa9970c37e0f9c03f5ecf7bc638f75
BLAKE2b-256 checksum
How to use checksums
367d0a711d838237bdb7411bdac605611c9632b2fa0cd9d8f9881d45628ba8fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.21

Release files / tortoise_pathway-0.2.1-py3-none-any.whl

Download URL tortoise_pathway-0.2.1-py3-none-any.whl
Size 42.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3408e4b07f3e8c53d6982f2a0425f87b1d60d7b759e6ea70745d7ddb67a93327
BLAKE2b-256 checksum
How to use checksums
09bbaef9192a2b1eb2d048e0950527c68d6593286dbb5815ca38723a5b6a33af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.21

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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