File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 55def migrate_files (
66 target_project : int ,
77 dest_project : int ,
8+ target_id : int ,
89 id_mapping : list [tuple [int , int ]]
910):
1011 with transaction .atomic ():
11- files = File .objects .filter (project_id = target_project )
12-
13- assert files .update (project_id = dest_project , rebound_project = target_project ), "No File to update"
14-
15- update_attributes_query = """
16- update attribute_group_attribute
17- set attribute_id = %s
18- where attributegroup_id in %s and attribute_id = %s;
19- """
12+ files = File .objects .filter (project_id = target_project , attributegroup__attribute__id = target_id )
2013
2114 ag_id_list = tuple ([
2215 str (uid ) for uid
@@ -29,5 +22,15 @@ def migrate_files(
2922 in id_mapping
3023 ]
3124
25+ assert ag_id_list
26+ assert query_values
27+ assert files .update (project_id = dest_project , rebound_project = target_project ), "No File to update"
28+
29+ update_attributes_query = """
30+ update attribute_group_attribute
31+ set attribute_id = %s
32+ where attributegroup_id in %s and attribute_id = %s;
33+ """
34+
3235 with connection .cursor () as cursor :
3336 cursor .executemany (update_attributes_query , query_values )
You can’t perform that action at this time.
0 commit comments