X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/0f2d00f9d7d5d28149707f66c719b28edfe51aed..49d0961a6f7f585f707cd08817f3e0a9f1a19212:/forum/migrations/0012_set_active_revision.py diff --git a/forum/migrations/0012_set_active_revision.py b/forum/migrations/0012_set_active_revision.py index 29e9030..24c419a 100644 --- a/forum/migrations/0012_set_active_revision.py +++ b/forum/migrations/0012_set_active_revision.py @@ -8,8 +8,15 @@ class Migration(DataMigration): def forwards(self, orm): for n in orm.Node.objects.all(): - n.active_revision = n.revisions.order_by('-id')[0] - n.save() + try: + n.active_revision = n.revisions.order_by('-id')[0] + n.save() + except: + r = orm.NodeRevision(author=n.author, body=n.body, title=n.title, revised_at=datetime.datetime.now(), + tagnames=n.tagnames, summary='Initial Revision', revision=1, node=n) + r.save() + n.active_revision = r + n.save() def backwards(self, orm):