【问题标题】:How do you create a new migration file using south without having to change the schema?如何在不更改架构的情况下使用 south 创建新的迁移文件?
【发布时间】:2014-10-28 23:41:55
【问题描述】:

所以我需要做的是更改整个数据库中某个字段的值。我不需要实际更改与架构相关的任何内容。像这样的东西。

def forwards(self, orm):
    the_things = Thing.objects.filter(widget="some value"):
    for thing in the_things:
      thing.widget = "some new value"
      thing.save()

def backwords(self, orm):
    the_things = Thing.objects.filter(widget="some new value"):
    for thing in the_things:
      thing.widget = "some value"
      thing.save()

我是使用南的新手,所以我不确定执行此类操作的最佳方法。仅手动制作迁移文件是不好的做法吗?似乎是因为运行./manage.py schemamigration app --auto 似乎遵循它生成的文件名中的命名约定。

【问题讨论】:

    标签: python database django migration django-south


    【解决方案1】:

    你需要一个data migration

    ./manage.py datamigration <your project> <descriptive_name>
    

    将为您创建一个空白迁移,然后您需要对其进行编辑。然后正常迁移。

    【讨论】:

      猜你喜欢
      • 2016-09-04
      • 1970-01-01
      • 2019-08-18
      • 1970-01-01
      • 1970-01-01
      • 2012-07-13
      • 1970-01-01
      • 2011-03-11
      • 2019-01-24
      相关资源
      最近更新 更多