File tree Expand file tree Collapse file tree
partner_programs/migrations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Generated by Django 4.2.3 on 2023-12-29 21:02
2+
3+ from django .db import migrations
4+
5+
6+ FIELDS_TO_DELETE = [
7+ 'password' ,
8+ 'formid' ,
9+ 'tranid' ,
10+ 'COOKIES' ,
11+ 'utm_term' ,
12+ 'utm_medium' ,
13+ 'utm_source' ,
14+ 'utm_content' ,
15+ 'utm_campaign' ,
16+ ]
17+
18+
19+ def normalize_profiles_data (apps , schema_editor ):
20+ PartnerProgramUserProfile = apps .get_model ("partner_programs" , "PartnerProgramUserProfile" )
21+ for profile in PartnerProgramUserProfile .objects .all ():
22+ program_data = profile .partner_program_data
23+ if any (field in program_data for field in FIELDS_TO_DELETE ):
24+ program_data ['tilda' ] = True
25+
26+ for field in FIELDS_TO_DELETE :
27+ if field in program_data :
28+ program_data .pop (field )
29+ profile .partner_program_data = program_data
30+ profile .save ()
31+
32+
33+ def do_nothing (apps , schema_editor ):
34+ pass
35+
36+
37+ class Migration (migrations .Migration ):
38+ dependencies = [
39+ ("partner_programs" , "0003_partnerprogramuserprofile_project_and_more" ),
40+ ]
41+
42+ operations = [
43+ migrations .RunPython (normalize_profiles_data , reverse_code = do_nothing ),
44+ ]
You can’t perform that action at this time.
0 commit comments