Skip to content

Commit 033ffd0

Browse files
fix
1 parent 7275701 commit 033ffd0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

scripts/file_project_rebound.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@
55
def 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)

0 commit comments

Comments
 (0)