Skip to content
This repository was archived by the owner on Apr 3, 2026. It is now read-only.
This repository was archived by the owner on Apr 3, 2026. It is now read-only.

Can't delete projects #959

Closed
Closed

Description

@Hagellach37

Can't delete a project due to a foreign key constraint.

Usually all project data can be deleted running: mapswipe_workers --verbose delete --project-ids '["a", "b"]'

However this is not working when mapping has happened already.

expected behaviour:

  • all project data in all tables should be removed (in firebase and postgres)
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 462, 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 103, in delete_project
    project.delete_from_postgres(project_id)
  File "/usr/local/lib/python3.8/dist-packages/mapswipe_workers/project_types/project.py", line 587, in delete_from_postgres
    p_con.query(sql_query, {"project_id": project_id})
  File "/usr/local/lib/python3.8/dist-packages/mapswipe_workers/auth.py", line 74, in query
    self._db_cur.execute(query, data)
psycopg2.errors.ForeignKeyViolation: update or delete on table "mapping_sessions" violates foreign key constraint "mapping_sessions_user_groups_mapping_session_id_fkey" on table "mapping_sessions_user_groups"
DETAIL:  Key (mapping_session_id)=(4751127) is still referenced from table "mapping_sessions_user_groups".

Activity

  1. moved this from Backlog to Ready for Production in Support and Maintenanceon Aug 2, 2024
  2. moved this from Ready for Production to Done and deployed in Support and Maintenanceon Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions