1
from django.db import connection
3
from pybb.models import Forum, Topic
5
DESCRIPTION = 'Add updated column to forum table'
8
cur = connection.cursor()
10
print 'Altering forum table'
11
cur.execute("ALTER TABLE pybb_forum ADD updated DATETIME NULL")
13
print 'Fixing updated values of forums'
14
for forum in Forum.objects.all():
16
topic = forum.topics.all().order_by('-updated')[0]
20
forum.updated = topic.updated