Skip to main content

next‑generation database migration tool

Project description

schemactl

framework‑agnostic database schema evolution tool for Python

schemactl is a next‑generation database migration tool built on top of SQLAlchemy metadata and Alembic autogeneration.

Unlike traditional migration tools, schemactl is designed as a schema evolution engine, not just a migration runner. It is architecture‑first, deterministic, and ready to integrate with LLMs, agents, and autonomous workflows.


Why schemactl?

Most migration tools are:

  • framework‑coupled
  • imperative and manual
  • hard to reason about at scale
  • unfriendly to AI‑assisted workflows

schemactl takes a different approach:

  • Framework‑agnostic – works with pure SQLAlchemy
  • Metadata‑driven – schema is the single source of truth
  • Diff‑based – migrations are generated from real schema changes
  • Deterministic – reproducible and auditable
  • AI‑ready – designed for LLM review, risk analysis, and human‑in‑the‑loop control

Core Concepts

Schema as Code

Your SQLAlchemy models (metadata) define the desired state of the database.

Base = declarative_base()

class User(Base):
    __tablename__ = "users"
    id = mapped_column(Integer, primary_key=True)
    email = mapped_column(String, unique=True)

schemactl compares this metadata against the actual database schema and generates migrations automatically.


Evolution, Not Just Migration

Instead of thinking in terms of "apply SQL files", schemactl models:

  • schema diffs
  • schema versions
  • schema state

This enables future features like:

  • automated rollback planning
  • migration safety scoring
  • AI‑assisted reviews
  • policy enforcement

Installation

pip install schemactl

CLI Overview

schemactl --help

Planned commands:

schemactl new       # generate a new migration from metadata diff
schemactl up        # create DB (if needed) and apply pending migrations
schemactl create    # create the database
schemactl drop      # drop the database
schemactl migrate   # run pending migrations
schemactl rollback  # rollback the last migration
schemactl down      # alias for rollback
schemactl status    # show migration status
#schemactl dump      # dump schema.sql
#schemactl load      # load schema.sql
schemactl wait      # wait for DB readiness

Usage

1. Generate a Migration

schemactl new \
  --message add_users_table

What happens:

  1. Connects to the database
  2. Loads SQLAlchemy metadata
  3. Uses Alembic autogenerate to compute schema diff
  4. Creates a new migration file under:
migrations/
└── versions/
    └── 20250101123000_add_users_table.py

2. Apply Migrations

schemactl up

What happens:

  • Creates the database if it does not exist
  • Ensures the schema_migrations table exists
  • Applies all pending migrations in order
  • Records applied revisions deterministically

Project Structure

.
├── schemactl/              # Main package source
│   ├── cli.py              # CLI commands
│   ├── services/           # Business logic and services
│   │   └── migration.py
│   │   └── model_loader.py
│   ├── adapters/           # Database and Alembic adapters
│   │   ├── alembic.py
│   │   └── database.py
├── migrations/             # Generated migration files
├── tests/                  # Unit and integration tests
├── pyproject.toml          # Project configuration (Poetry)
└── poetry.lock             # Poetry lock file

This structure follows Clean Architecture and keeps infrastructure concerns isolated.


Design Principles

  • Architecture first, code second
  • Prefer declarative over imperative
  • Explicit state tracking
  • Simple core, extensible edges

Status

⚠️ Early development / experimental

APIs may change. Migration format is not yet stable.


License

MIT


Contributing

Contributions are welcome, especially in:

  • migration safety
  • rollback logic
  • Async / cloud databases

Design discussions > code dumps.

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

schemactl-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

schemactl-0.1.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file schemactl-0.1.0.tar.gz.

File metadata

  • Download URL: schemactl-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for schemactl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 caafebe9c2255c2b8a8cdafc91595afaeb1bd918cfb5ffe5608e3d9f44c36e26
MD5 06ae6a169f66f0a4b2252ba50cb56d28
BLAKE2b-256 20a2ced8365370ce482cac0280c0b30f5963d980e27e118350e449495a015186

See more details on using hashes here.

File details

Details for the file schemactl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: schemactl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for schemactl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3040c74b361cfe819c735a42a2b784c5d4de87d935f6538f601325680e39ab09
MD5 51f08201d1aa23790fa599d677036016
BLAKE2b-256 11daf4abe1541dc3c082875329e1d8fcad5af2a5f17aa9efbf3d787aa9e50fb0

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