python-mapswipe-workers
python-mapswipe-workers copied to clipboard
delete projects is not working due to foreign key constraint
trying to run this command:
docker compose run --rm mapswipe_workers_creation mapswipe_workers -v delete --project-ids='["-NOJYMJyWFMwZtxqW0Ms", "-NOKFgUwMbcXcjwoMkeg"]'
introducing the new tables for aggregated stats, breaks our workflow to delete projects.
Traceback (most recent call last):
File "/usr/local/bin/mapswipe_workers", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/mapswipe_workers/mapswipe_workers.py", line 460, in run_delete_project
if delete_project.delete_project(project_ids):
File "/usr/local/lib/python3.8/dist-packages/mapswipe_workers/firebase_to_postgres/delete_project.py", line 115, in delete_project
pg_db.query(sql_query, {"project_id": project_id})
File "/usr/local/lib/python3.8/dist-packages/mapswipe_workers/auth.py", line 68, in query
self._db_connection.commit()
psycopg2.errors.ForeignKeyViolation: update or delete on table "projects" violates foreign key constraint "aggregated_aggregate_project_id_01e6f153_fk_projects_" on table "aggregated_aggregateduserstatdata"
DETAIL: Key (project_id)=(-NOJYMJyWFMwZtxqW0Ms) is still referenced from table "aggregated_aggregateduserstatdata".