[ckan-dev] problem with purging groups

Daniel Lau daniel.lau at sirca.org.au
Fri Nov 14 05:16:07 UTC 2014


Hi all

We are building a system that uses CKAN as a data portal but periodically
we may need to programmatically delete and purge datasets from it (purged
because we may need to reuse the dataset name).

However we noticed that after purging a dataset from CKAN (using the paster
command), we ended up with empty groups that has no dataset (because it was
for the purged datasets). When we try to delete and purge the group, the
operation failed.

After a bit of investigation, it turned out when we purged the datasets
(using the paster command), only the datatset (or package) records were
removed, but the member records that tie the 'datasets' to the 'groups'
were left behind. Hence an attempt to purge the group (via
purge_group action) will fail due to foreign key restriction.

We went further and started removing membership between datasets and groups
prior to purging (using the member_delete action). Now when we attempt to
delete/purge the empty groups again, it throws another error and this time
it is related to "group revision records" (sadly this time there is no CKAN
action that can delete or purge 'group revision').

We are thinking it can't be this difficult to purge an empty CKAN group? I
would have thought when the paster purge is executed on the dataset, the
action should remove all dataset records and along side any other records
that point to the deleted dataset (e.g. group membership). And that when we
perform a purge_group action, it should also automatically remove records
with foreign key pointing to the group to purge (e.g. group membership,
group revision, etc)

Are we doing something wrong or is this limitation in the current version
of CKAN?
Or perhaps we should turn off revision tracking for group (if there is such
a function)? But is that just a workaround, and the correct approach should
be to enhance CKAN to automatically remove related records when a
dataset/group is purged.

Thanks in advance if anyone can help out with this problem.

Kind regards
-- 

*Daniel Lau* | Software Engineer | Sirca Ltd

daniel.lau at sirca.org.au | www.sirca.org.au

Tel: +61 2 8355 2523

Level 4, 55 Harrington St, The Rocks NSW 2000

PO Box H58, Australia Square, Sydney NSW 1215
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20141114/5cd8bd14/attachment-0002.html>


More information about the ckan-dev mailing list