解决迁移冲突。

django-migration-resolver-hook的Python项目详细描述


PyPI version

django-migration-resolver-hook

Django迁移解析器确保迁移文件始终保持有序,而不管远程更改如何。在

问题:

使用Django的manage.py makemigrations命令生成的迁移文件,您可以运行 生成的迁移文件可能与 远程的主/默认分支大多数CI服务器都能够通过运行基于 您的本地分支通过发现重复的迁移节点合并回基础分支。在

解决方案:

这个软件包旨在通过在遍历应用程序的同时使用双链接列表来解决这个问题 以检测潜在的文件迁移和存储冲突。在

{a3}根据上次修改的时间^对文件进行排序。在

:警告:这并不总是准确的,可能需要手动检查以验证更改。在

NOTE: This doesn't require Django's installed apps concept when using CLI commands since this is totally file based and should be executed within the root/app folders.

目录

  1. Installation

  2. Usage

    一、Use Case

    二。Using Auto migration resolver

    三、Using Static migration resolver

安装

$ pip install django-migration-resolver-hook
诗歌
^{pr2}$

使用

用例

远程
|--- migrations
       |---- ...
       |---- 0007_auto_20200112_2328.py # Shared between remote and local repo
       |---- 0008_auto_20200113_4328.py # Only exists on remote
       |---- 0009_auto_20200114_4532.py
       |---- 0010_auto_20200115_1632.py
本地回购
|--- migrations
       |---- ...
       |---- 0007_auto_20200112_2328.py  # Shared between remote and local repo
       |---- 0008_auto_20200114_5438.py  # Only exists locally which raises duplicate migration nodes errors.

Since this is now out of sync with the remote branch to sync changes:


使用自动迁移解析器


CLI命令:auto_migration_resolver

通过提供以下功能自动检测和修复迁移文件:

  • --app-name:Django应用程序的app_名称。在
  • --strategy:用于解决迁移错误的策略(选项:“reseed”/“inline”)。(默认为:“重新设定种子”)
  • --exclude:应该忽略的迁移文件的列表。在
  • --commit:对移动文件old->;new之后的更改执行git commit。在
  • --verbose:详细的命令执行。在
用法:
$ auto_migration_resolver --app-name my_app --commit --verbose
输出
...

使用静态迁移解析器


CLI命令:migration_resolver

通过提供以下功能修复迁移:

  • --app-name:Django应用程序的app_名称。在
  • --last:远程的最后一个迁移文件,该文件应该是冲突迁移的种子,带或不带后缀。在
  • --conflict:需要从上一个迁移文件重新设定种子的迁移文件。在
  • --commit:对移动文件old->;new之后的更改执行git commit。在
  • --verbose:详细的命令执行。在
用法:
$ migration_resolver --app-name my_app --last 0010_auto_20200115_1632 --conflict 0008_auto_20200114_5438 --commit --verbose
输出
Fixing migrations...
Updating the conflicting migration file 0008_auto_20200114_5438.py
Succefully updated: 0008_auto_20200114_5438.py.
Renaming the migration file from 0008_auto_20200114_5438.py to 0011_auto_20200114_5438.py
Successfully renamed the migration file.
[my-test-branch c18fca41e] Resolved migration conflicts for 0008_auto_20200114_5438.py → 0011_auto_20200114_5438.py
1 file changed, 1 insertion(+), 1 deletion(-)
rename my_app/migrations/{0008_auto_20200114_5438.py => 0011_auto_20200114_5438.py} (99%)

更多选择

$ migration_resolver --help
usage: migration_resolver [-h] [--auto-detect] [--verbose] --app-name APP_NAME --last LAST --conflict CONFLICT [--commit]

Resolve duplicate migration nodes.

optional arguments:
  -h, --help           show this help message and exit
  --auto-detect        Auto-detect and fix migration errors. (Not supported)
  --verbose            Verbose output
  --app-name APP_NAME  App Name
  --last LAST          The glob/full name of the final migration file.
  --conflict CONFLICT  The glob/full name of the final migration file with the conflict.
  --commit             Commit the changes made.

当远程的迁移文件与以前的迁移文件冲突时使用vsc(git/mercurial) 本地迁移。在

待办事项:

  • [x] 自动检测并解决迁移节点的错误。在
  • []使用async/await处理读取节点来加快执行速度。在
  • []在应用迁移的情况下添加对数据库unapply迁移的支持。在
  • []添加在操作链中出现故障时回滚任何更改的支持。在
  • []VCS支持现在只支持git(扩展到mercurial)。在
  • []记录自动迁移策略。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
尝试运行JFLAP。戴软呢帽的罐子23。Java正在抛出异常   无引用的java数组布尔复制   hibernate如何在java SE应用程序中使用JPA EntityManager   java如何使用ORMLite在SQLite中持久化JavaFX属性?   java无法将项目部署到GAE   java:谷歌地图维基百科层   java Resultset(getter/setter类)对象在第二次执行时未删除旧值   s中的java struts2:选择列表>请求的列表键“”作为集合/数组/映射/枚举/迭代器类型   java如何在Karaf 4.0.5中获得BaseDao中的entityManager?   java VSCode未从控制台读取西里尔文   java字体。createFromAsset()返回字体的空指针异常   java错误:将Android Studio从0.6.1更新到0.8.9后,没有合适的构造函数