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 issues with code style that are common for AI generated code.

🤓 Code contributions ans assistance with testing is welcome and appreciated!

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
  • 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 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>

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.2.tar.gz (30.2 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.2-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tortoise_pathway-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2a1720d1ae25c38a0b214b0bc7cd7787910dd151d7504091bbb4ddc39b608b77
MD5 cd77b8ce0ba1e09e2e40d78d65f8a50d
BLAKE2b-256 82b0606212796ac3cbc75b292d81d55170ea4654d6aee30b0fae36802f16818a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tortoise_pathway-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 979387ce812a5d516a0a2ed2e6f231410e3ad3af0114f0f42526431a1b9078fd
MD5 b5f1910dd72ed36e4d9aafd62189da10
BLAKE2b-256 53c5194ff4267885e6d39e360f65a6c0988c23634a423936df0bb0a2d0b5c72b

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