Skip to content

Commit 46ab91e

Browse files
committed
Added a migration to set an explicit content-type for Message objects when missing.
- Legacy-Id: 17350
1 parent 0b3ac2a commit 46ab91e

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright The IETF Trust 2020, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
# Generated by Django 1.11.20 on 2019-05-21 14:27
4+
5+
6+
from __future__ import absolute_import, print_function, unicode_literals
7+
8+
from tqdm import tqdm
9+
10+
from django.db import migrations
11+
12+
import debug # pyflakes:ignore
13+
14+
15+
def forward(apps, schema_editor):
16+
17+
Message = apps.get_model('message', 'Message')
18+
19+
for m in tqdm(Message.objects.filter(content_type='')):
20+
m.content_type = 'text/plain'
21+
m.save()
22+
23+
def reverse(apps, schema_editor):
24+
pass
25+
26+
class Migration(migrations.Migration):
27+
28+
dependencies = [
29+
('message', '0009_fix_address_lists'),
30+
]
31+
32+
operations = [
33+
migrations.RunPython(forward, reverse),
34+
]

0 commit comments

Comments
 (0)