人类迁移管理器
nomade的Python项目详细描述
^{1}$ 在
Python Migration Manager for Humans :camel:
Nomade是一个简单的迁移管理器工具,其目标是易于与任何ORM(例如SQLAlchemy,Peewee,Pony)和数据库(例如SQLite,MySQL,PostgreSQL)集成。它基本上是一个命令行界面(CLI)工具,它通过将更改应用于数据库模式并存储当前迁移ID来管理迁移(Python文件)
这个工具的灵感来源于alembic(如果您使用SQLAlchemy作为ORM,那么应该考虑使用alembic)。在
Note: this project is still under development so you may find bugs. If you find any bug, feel free to contribute by creating an issue and/or submitting a PR to fix it.
安装
使用pip安装Nomade:
$ pip install nomade
快速入门
初始化Nomade项目:
^{pr2}$它将创建以下项目结构:
.
├── nomade
│ ├── template.py.j2
│ └── migrations
└── pyproject.toml
在pyproject.toml
文件中定义Nomade设置,例如:
[tool.nomade]migrations="nomade/migrations"template="nomade/template.py.j2"connection-string="sqlite:///nomade.db"date-format="%d/%m/%Y"name-format="{date}_{time}_{id}_{slug}"
然后,创建第一个迁移:
$ nomade migrate "Create first table"
在迁移文件中实现upgrade
和downgrade
函数。在
然后将迁移应用到数据库:
$ nomade upgrade head
要了解更多Nomade功能,请阅读文档或致电寻求帮助:
$ nomade --help
Usage: nomade [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
current Show the current migration.
downgrade Downgrade migrations.
history Show migrations history.
init Init a Nomade project.
migrate Create a new migration.
stamp Stamp a specific migration to the database.
upgrade Upgrade migrations.
version Show Nomade version.
如何作出贡献
- 检查是否存在未解决的问题,或者打开一个新的问题,围绕一个特性想法或一个bug展开讨论。在
- 通过阅读Contributor's Guide对项目更加熟悉。在
- 项目
标签: