Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Mongrade

轻量、可验证、可恢复的 MongoDB 版本化迁移工具。

Mongrade 使用 PyMongo,最低支持 Python 3.7。引擎独立于服务框架,提供单链版本管理、静态迁移计划、并发互斥、后置验证、checkpoint 恢复及旧库显式承接。它是纯 Python 包,目标制品为 py3-none-any wheel 和 sdist。

安装和使用

python -m pip install mongrade==0.1.0a2
mongrade --version
mongrade graph
mongrade diagnose
mongrade plan --evidence files/maintenance.json

当前预览版为 0.1.0a2,默认业务迁移目录为 mongrade/;可在发布到PyPI后使用上述命令,离线环境使用经过校验的wheel。已发布的0.1.0a1仍使用旧目录。预览版不承诺生产就绪。python -m mongrade 与控制台入口相同。连接通过运行时环境变量 MONGRADE_URI 注入,URI 必须声明与项目一致的业务库及 authSource;不要将凭据写入项目或日志。

公共 API

from mongrade import connect, load_catalog, plan, migrate, verify

catalog = load_catalog("mongrade/project.json")
with connect(uri, catalog) as client:
    approved = plan(client, catalog, evidence=evidence)
    # 在独立的发布审核阶段固定 approved.sha256 及本次维护材料。
    migrate(client, catalog, approved, evidence)
    verify(client, catalog)

业务服务自行发布 mongrade/project.json 和 versions/,脚本实现 upgrade(context);诊断不导入或执行脚本。完整格式和恢复边界见 接入指南 与 设计。

边界

  • 默认部署角色;生成模板必须显式使用 --role author。适配器注入角色后不允许命令行提升角色。
  • 失败保留锁与运行状态,必须经过受审的恢复流程;没有自动降级或跨数据库原子事务。
  • 迁移脚本是受信发布代码,上下文不是安全沙箱;禁止业务 HTTP、UAC、DataSearch、MQ 调用。
  • 首版拒绝多物理业务库和分片写入,备份恢复材料由 DBA 审核,引擎复核文件摘要、时效及范围。
  • 本包不包含 CommonLib 的 SQL 后端、服务启动器或混合数据库部署编排。

开发与发布

python -m pip install ".[dev]"
python -m pytest
python -m ruff format --check src test
python -m ruff check src test
python -m mypy
python -m build

使用独立虚拟环境,测试临时产物统一写入 tmp/。发布工作流检出Release(含预发布)对应 tag,版本检查、质量检查、构建和兼容性验证全部通过后,先将同一批 wheel/sdist 上传到当次 GitHub Release,再上传 PyPI;认证和首次发布设置见 发布指南。仓库私有不代表 PyPI 包私有。许可证尚待所有者确定,本次迁移不擅自授予开源许可。

离线部署应预先为目标解释器和操作系统准备 PyMongo 依赖;已有匹配依赖时可用 python -m pip install --no-index --no-deps ./mongrade-0.1.0a2-py3-none-any.whl。包体跨平台不代表 PyMongo 的二进制依赖可跨平台复用。

业务目录 mongrade/ 与安装包同名但不是Python包:只放project.json、versions和迁移材料,不放 __init__.py 或 __main__.py,不要把它加入PYTHONPATH。CLI仍从服务根目录运行,不切换进该目录;不自动发现或回退旧mongo_migrations目录。

Metadata

Release files for mongrade 0.1.0a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongrade 0.1.0a2
File Size Uploaded Provenance Actions
mongrade-0.1.0a2.tar.gz 43.7 kB Without provenance Details for mongrade-0.1.0a2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mongrade 0.1.0a2
File Interpreter ABI Platform Actions
mongrade-0.1.0a2-py3-none-any.whl Python 3 none any Details for mongrade-0.1.0a2-py3-none-any.whl

Total release size: 68.6 kB

Release files / mongrade-0.1.0a2.tar.gz

Download URL mongrade-0.1.0a2.tar.gz
Size 43.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f7447d28b052f916364e3b4b70f2e326aaae58efaf60b974a5ac81729127609e
BLAKE2b-256 checksum
How to use checksums
ead5a5ff9b8cb83bc7b7a4fdabad397d707b4440970b053a9c9ab59082b8c79f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mongrade-0.1.0a2-py3-none-any.whl

Download URL mongrade-0.1.0a2-py3-none-any.whl
Size 24.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e3f973ced2ee8a67dc79c73dccc4d16c012dbf4db80067f16a7004bf011d99b
BLAKE2b-256 checksum
How to use checksums
5da4efbc117cad0910f4165a28be6f825efe0a0563f6fde268f97729a1bdd102
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for mongrade 0.1.0a2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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