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+ # Generated by Django 2.2.16 on 2020-09-22 07:58
2+
3+ import sys
4+ import debug
5+
6+ from django .db import migrations
7+
8+
9+ def forward (apps , schema_editor ):
10+ Document = apps .get_model ('doc' , 'Document' )
11+ DocAlias = apps .get_model ('doc' , 'DocAlias' )
12+
13+ docs_without_alias = Document .objects .filter (docalias__isnull = True )
14+ debug .show ('docs_without_alias.count()' )
15+
16+ bad_aliases = DocAlias .objects .filter (name__in = docs_without_alias .values_list ('name' ))
17+ debug .show ('bad_aliases.count()' )
18+ bad_aliases .delete ()
19+
20+ for doc in docs_without_alias :
21+ DocAlias .objects .create (name = doc .name ).docs .add (doc )
22+
23+ def reverse (apps , schema_editor ):
24+ pass
25+
26+ class Migration (migrations .Migration ):
27+
28+ dependencies = [
29+ ('doc' , '0036_orgs_vs_repos' ),
30+ ]
31+
32+ operations = [
33+ migrations .RunPython (forward , reverse ),
34+ ]
You can’t perform that action at this time.
0 commit comments