次のような簡単な移行があります。
class Migration(SchemaMigration):
def forwards(self, orm):
db.add_column('activities_newsitem', 'related_story', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['projects.Story'], null=True, blank=True),keep_default=True)
残念ながら、それは失敗し、その理由はわかりません。以下は出力です。列の追加クエリが正常に実行されることに注意してください。実際、DB を見ると、列は正しくそこにあります。
しかし、何らかの理由で、後でドロップ列を実行しているため、失敗します。なぜそれをしているのですか?
DEBUG south execute "ALTER TABLE `activities_newsitem` ADD COLUMN `related_story_id` integer NULL;" with params "[]" (generic.py:145)
DEBUG south execute "ALTER TABLE `activities_newsitem` ADD CONSTRAINT `related_story_id_refs_id_3d3841088db0fdb0` FOREIGN KEY (`related_story_id`) REFERENCES `projects_story` (`id`);" with params "[]" (generic.py:145)
DEBUG south execute "CREATE INDEX `activities_newsitem_related_story_id` ON `activities_newsitem` (`related_story_id`);" with params "[]" (generic.py:145)
DEBUG south execute "ALTER TABLE `activities_newsitem` ADD COLUMN `related_story_id` integer NULL;" with params "[]" (generic.py:145)
DEBUG south execute "ALTER TABLE `activities_newsitem` ADD CONSTRAINT `related_story_id_refs_id_3d3841088db0fdb0` FOREIGN KEY (`related_story_id`) REFERENCES `projects_story` (`id`);" with params "[]" (generic.py:145)
DEBUG south execute "ALTER TABLE `activities_newsitem` DROP COLUMN `related_story_id` CASCADE;" with params "[]" (generic.py:145)
! Error found during real run of migration! Aborting.
! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.
助けてくれてありがとう