server/python/django2/renkanmanager/migrations/0008_modification_date_migrate_data.py
equal
deleted
inserted
replaced
|
1 # -*- coding: utf-8 -*- |
|
2 # Generated by Django 1.9.4 on 2016-06-21 08:09 |
|
3 from __future__ import unicode_literals |
|
4 |
|
5 import json |
|
6 |
|
7 from django.db import migrations |
|
8 |
|
9 def adjust_rev_modification_date(apps, schema_editor): |
|
10 Revision = apps.get_model('renkanmanager', 'Revision') |
|
11 |
|
12 for rev in Revision.objects.all(): |
|
13 content = json.loads(rev.content) |
|
14 if rev.modification_date: |
|
15 content['updated'] = rev.modification_date.isoformat(' ') |
|
16 rev.content = json.dumps(content) |
|
17 rev.save() |
|
18 |
|
19 class Migration(migrations.Migration): |
|
20 |
|
21 dependencies = [ |
|
22 ('renkanmanager', '0007_foreign_key_final'), |
|
23 ] |
|
24 |
|
25 operations = [ |
|
26 migrations.RunPython(adjust_rev_modification_date) |
|
27 ] |