gpt4 book ai didi

django - 如何在 Django 中压缩压缩迁移?

转载 作者:行者123 更新时间:2023-12-04 16:37:45 25 4
gpt4 key购买 nike

例如,我有 50 次迁移,并且我已将所有迁移压缩到 0001_initial.py 并在再次达到 50 次迁移后。我如何压制迁移?

最佳答案

在压缩新迁移之前,您需要将压缩的迁移转换为正常迁移,如 documentation 中所述。 (在本节末尾):

You must then transition the squashed migration to a normal migrationby:

  • Deleting all the migration files it replaces.
  • Updating all migrations that depend on the deleted migrations to depend on the squashed migration instead.
  • Removing the replaces attribute in the Migrationclass of the squashed migration (this is how Django tells that it is asquashed migration).

一旦您删除了被压缩的原始迁移以及所有引用,被压缩的迁移将成为“正常”迁移,您将能够再次压缩它们。

关于django - 如何在 Django 中压缩压缩迁移?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36716491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com