Some fixups for migration 505.

This commit is contained in:
Rob Hudson 2012-11-14 22:01:12 -08:00
Родитель f866ed0439
Коммит 45d3e3518d
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -97,6 +97,18 @@ def run():
print 'Version log [%s] version id updated: %s => %s' % (
lav_id, old_version.id, version.id)
# There are stale activity logs without the _mkt suffix that we
# need to deal with to avoid integrity errors when we delete
# the version.
cursor.execute('''
SELECT id, activity_log_id FROM log_activity_version
WHERE version_id=%s''', (old_version.id,))
for row in cursor.fetchall():
cursor.execute(
'DELETE FROM log_activity_version WHERE id=%s' % (row[0],))
cursor.execute(
'DELETE FROM log_activity WHERE id=%s' % (row[1],))
# Copy over important fields if not set on current version.
if not version.releasenotes and old_version.releasenotes:
version.releasenotes = old_version.releasenotes
@ -133,7 +145,8 @@ def run():
cursor.execute('''
DELETE FROM files
WHERE version_id=%s''', (old_version.id,))
print 'Deleted files attached to version [%s]' % old_version.id
print 'Deleted files records attached to version [%s]' % (
old_version.id,)
# Delete the version itself.
cursor.execute('''