File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Copyright The IETF Trust 2019, All Rights Reserved
2+ # -*- coding: utf-8 -*-
3+ # Generated by Django 1.11.20 on 2019-06-10 04:36
4+ from __future__ import unicode_literals
5+
6+ import sys
7+
8+ from tqdm import tqdm
9+
10+ from django .db import migrations , models
11+
12+
13+ def forward (apps , schema_editor ):
14+ DocAlias = apps .get_model ('doc' ,'DocAlias' )
15+ sys .stderr .write ('\n ' )
16+ for a in tqdm (DocAlias .objects .all ()):
17+ a .docs .add (a .document )
18+
19+ def reverse (apps , schema_editor ):
20+ DocAlias = apps .get_model ('doc' ,'DocAlias' )
21+ sys .stderr .write ('\n ' )
22+ for a in tqdm (DocAlias .objects .all ()):
23+ a .document = a .document
24+ a .save ()
25+
26+ class Migration (migrations .Migration ):
27+
28+ dependencies = [
29+ ('doc' , '0022_document_primary_key_cleanup' ),
30+ ]
31+
32+ operations = [
33+ migrations .AddField (
34+ model_name = 'docalias' ,
35+ name = 'docs' ,
36+ field = models .ManyToManyField (related_name = 'docalias' , to = 'doc.Document' ),
37+ ),
38+ migrations .RunPython (forward , reverse ),
39+ migrations .RemoveField (
40+ model_name = 'docalias' ,
41+ name = 'document' ,
42+ ),
43+ ]
You can’t perform that action at this time.
0 commit comments