tortoise-orm的迁移工具aerich

tortoise-orm的迁移工具aerich

2023年7月20日发(作者:)

tortoise-orm的迁移⼯具aerich安装aerichpip install aerich创建, 构建数据模型from tortoise import Model, fieldsclass User(Model): """ ⽤户基础信息 """ name = eld(max_length=24, description="姓名") id_no = eld(max_length=24, description="⾝份证号")创建配置⽂件,配置TORTOISE_ORMTORTOISE_ORM = { "connections": {"default": "mysql://root:password@localhost/basename"}, "apps": { "models": { # models对应上⾯创建的 "models": ["", "models"],

"default_connection": "default", }, },}⽣成初始化数据配置, SE_ORM是上⾯配置TORTOISE_ORM的路径aerich init -t SE_ORM⽣成后会⽣成⼀个⽂件和⼀个migrations⽂件夹初始化数据库aerich init-db修改数据模型后⽣成迁移⽂件aerich migrate#

在后⾯加 --name=xxx,

可以指定⽂件名执⾏迁移aerich upgrade回退到上⼀个版本aerich downgrade

发布者:admin,转转请注明出处:http://www.yc00.com/web/1689824580a288910.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信