It is not possible to delete a template when it is used by one or more datasets.
The delete button is present and clickable:
After a deletion request, nothing is deleted from the interface, but an error appears in the server logs:
Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 4.0.1.payara-p1.v202304041433): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: update or delete on table "template" violates foreign key constraint "fx_dataset_template_id" on table "dataset"
Detail: Key (id)=(222) is still referenced from table "dataset".
Error Code: 0
Call: DELETE FROM TEMPLATE WHERE (ID = ?)
bind => [1 parameter bound]
Query: DeleteObjectQuery(edu.harvard.iq.dataverse.Template@de)
Proposed solution:
when deleting a template, set the template_id of the dataset and datasetfield to null.
The SQL constraint will be respected and the deletion can be performed.
It is not possible to delete a template when it is used by one or more datasets.
The delete button is present and clickable:
After a deletion request, nothing is deleted from the interface, but an error appears in the server logs:
Proposed solution:
when deleting a template, set the
template_id
of the dataset anddatasetfield
tonull
. The SQL constraint will be respected and the deletion can be performed.