]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/migrations/0012_set_active_revision.py
Applies some of the Justin Grant's patches.
[osqa.git] / forum / migrations / 0012_set_active_revision.py
index 29e9030e2b6f2dd94e482b449f12b303db68c524..24c419a7d0ee1beed5072f4c0a6ba9eb21110523 100644 (file)
@@ -8,8 +8,15 @@ class Migration(DataMigration):
     \r
     def forwards(self, orm):\r
         for n in orm.Node.objects.all():\r
-            n.active_revision = n.revisions.order_by('-id')[0]\r
-            n.save()\r
+            try:\r
+                n.active_revision = n.revisions.order_by('-id')[0]\r
+                n.save()\r
+            except:\r
+                r = orm.NodeRevision(author=n.author, body=n.body, title=n.title, revised_at=datetime.datetime.now(),\r
+                                 tagnames=n.tagnames, summary='Initial Revision', revision=1, node=n)\r
+                r.save()\r
+                n.active_revision = r\r
+                n.save()\r
     \r
     \r
     def backwards(self, orm):\r