更新:mysql-5.5.30-1.fc18.x86_64
和
MySQL-python==1.2.4
Django==1.4.2
South==0.7.6
以下作品:
class Migration(SchemaMigration_:
def forwards(self, orm):
db.rename_column('app_model', 'old_id', 'new_id')
db.alter_column('app_model', 'new_id',
self.gf('django.db.models.fields.related.ForeignKey')(
blank=True,
null=True,
to=orm['app.OtherModel']
))
def backwards(self, orm):
db.rename_column('app_model', 'new_id', 'old_id')
db.alter_column('app_model', 'old_id',
self.gf('django.db.models.fields.related.ForeignKey')(
blank=True,
null=True,
to=orm['app.OtherModel']
))
正如@Eloff 评论的那样,South 由于未知原因找不到原始的 FK,但这似乎并不重要。不需要数据迁移(我相信),因为 pk 值不应该改变。
字段规范(使用self.gf
)取自 South 自动生成的迁移以保持一致性。