Cannot delete actor if it has links to an item that has been deleted
Call:
curl --location --request GET 'https://sshoc-marketplace-api.acdh-dev.oeaw.ac.at/api/actors/18004' \
--header 'Authorization: XXX'
returns:
{
"id": 18004,
"name": "Frank Fischer 0005",
...
"items": [
{
"id": 63505,
"category": "publication",
"label": "Faust Times Eighteen - A Network Analysis of Theatre Plays Around the Myth of Faust",
"persistentId": "GzPPp6",
"lastInfoUpdate": "2022-01-12T11:47:57+0000"
},
{
"id": 63504,
"category": "publication",
"label": "Faust Times Eighteen - A Network Analysis of Theatre Plays Around the Myth of Faust",
"persistentId": "GzPPp6",
"lastInfoUpdate":no_bicycles: "2022-01-12T11:47:52+0000"
}
]
}
Item with persistantId GzPPp6
doesn't exist anymore (I deleted it), so:
curl --location --request GET 'https://sshoc-marketplace-api.acdh-dev.oeaw.ac.at/api/publications/GzPPp6' \
--header 'Authorization: XXX'
returns 404 (as expected)
I want to delete the actor:
curl --location --request DELETE 'https://sshoc-marketplace-api.acdh-dev.oeaw.ac.at/api/actors/18004' \
--header 'Authorization: XXX'
and I get:
{
"timestamp": "2022-01-13 13:45:30",
"status": 500,
"error": "could not execute statement; SQL [n/a]; constraint [item_contributor_actor_id_fk]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement"
}
From the logs:
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "actors" violates foreign key constraint "item_contributor_actor_id_fk" on table "items_contributors"
Detail: Key (id)=(18004) is still referenced from table "items_contributors".