[ckan-dev] purging revisions
Sean Hammond
sean.hammond at okfn.org
Tue Jul 24 10:18:50 UTC 2012
> Given an extension ("myextension") that introduces it's own revisioned
> model entities, how can I ensure that the associated revisions are
> returned by Package.all_related_revisions?
I'm not sure you can do this without modifications to CKAN core,
ckan.model.package.Package.all_related_revisions() looks specifically
for PackageRevision, PackageTagRevision, PackageExtraRevision and
ResourceRevisision objects, it doesn't look for your custom entities
introduced by your extension.
> The issue I'm running into is that when I delete and purge a package, I
> receive the following errors:
>
> Problem purging revision fe09a50b-3f65-4bda-a555-6ba39cf6f3f2:
> (IntegrityError) update or delete on table "revision" violates foreign key
> constraint "myextension_group_revision_id_fkey" on table
> "myextension_group" DETAIL: Key
> (id)=(fe09a50b-3f65-4bda-a555-6ba39cf6f3f2) is still referenced from table
> "myextension_group". 'DELETE FROM revision WHERE revision.id = %(id)s'
> {'id': u'fe09a50b-3f65-4bda-a555-6ba39cf6f3f2'}
I think it's considered bad practice for extensions to introduce foreign
keys against core models, as it causes problems:
http://docs.ckan.org/en/latest/writing-extensions.html#libraries-available-to-extensions
More information about the ckan-dev
mailing list