File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
mapswipe_workers/mapswipe_workers/firebase_to_postgres Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ class Type(models.IntegerChoices):
1616 value = models .CharField (max_length = 225 , null = True )
1717
1818
19+ # NOTE: Django generated table_name is used in mapswipe_workers->delete_project.py
1920class AggregatedUserStatData (Model ):
2021 # Ref Fields
2122 project = models .ForeignKey (Project , on_delete = models .CASCADE , related_name = "+" )
@@ -35,6 +36,7 @@ class Meta:
3536 )
3637
3738
39+ # NOTE: Django generated table_name is used in mapswipe_workers->delete_project.py
3840class AggregatedUserGroupStatData (Model ):
3941 # Ref Fields
4042 project = models .ForeignKey (Project , on_delete = models .CASCADE , related_name = "+" )
Original file line number Diff line number Diff line change @@ -111,6 +111,14 @@ def delete_project(project_ids: list) -> bool:
111111 pg_db .query (sql_query , {"project_id" : project_id })
112112 sql_query = "DELETE FROM groups WHERE project_id = %(project_id)s;"
113113 pg_db .query (sql_query , {"project_id" : project_id })
114+ # -- Table from django/apps/aggregated/models.py. Used to cache stats data
115+ # NOTE: Django doesn't support database-level CASCADE delete
116+ # https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.ForeignKey.on_delete
117+ sql_query = "DELETE FROM aggregated_aggregateduserstatdata WHERE project_id = %(project_id)s;"
118+ pg_db .query (sql_query , {"project_id" : project_id })
119+ sql_query = "DELETE FROM aggregated_aggregatedusergroupstatdata WHERE project_id = %(project_id)s;"
120+ pg_db .query (sql_query , {"project_id" : project_id })
121+ # Finally delete the project
114122 sql_query = "DELETE FROM projects WHERE project_id = %(project_id)s;"
115123 pg_db .query (sql_query , {"project_id" : project_id })
116124
You can’t perform that action at this time.
0 commit comments