Skip to main content

A schema migration tool for Tortoise ORM

Project description

Tortoise Pathway

⚠️ This project is in VERY early development and not yet ready for production use. Most things are broken and they will break again, APIs will change.

⚠️ Most of the code is written with Claude, there are some issues with code style.

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

Features

  • Generate schema migrations from Tortoise models
  • Apply and revert migrations
  • No need for a database connection to generate migrations

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 your models:

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

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>

Known Limitations

  • Limited support for databases

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

tortoise_pathway-0.1.1.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tortoise_pathway-0.1.1-py3-none-any.whl (36.5 kB view details)

Uploaded Python 3

File details

Details for the file tortoise_pathway-0.1.1.tar.gz.

File metadata

  • Download URL: tortoise_pathway-0.1.1.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.18

File hashes

Hashes for tortoise_pathway-0.1.1.tar.gz
Algorithm Hash digest
SHA256 89fa03c122172197129da7091582c36a0eda5760f1e6c9d5fc403ffccb94a7c0
MD5 b7ad461894ad5b719ba72d502aaae706
BLAKE2b-256 00e0ed4e483941253364eaa2cecb0694a5e3cc154d47f43cb6c3020ea1fea3d8

See more details on using hashes here.

File details

Details for the file tortoise_pathway-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tortoise_pathway-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7a0fc156f1f4b25af60b467a05ff887bd420fb9c2369e45a506c31b7cd0e8eb
MD5 9fc439c04aebf9ea5a895981fc3a23f4
BLAKE2b-256 a7b3ec7837619438b129c1b0e362d112f24420e747768c637de60febefc727f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page