diff --git a/ckanext/harvest/logic/action/update.py b/ckanext/harvest/logic/action/update.py index 62e4c08..ae6f431 100644 --- a/ckanext/harvest/logic/action/update.py +++ b/ckanext/harvest/logic/action/update.py @@ -140,14 +140,22 @@ def harvest_source_clear(context,data_dict): delete from resource_group where package_id in (select id from package where state = 'to_delete'); ''' + # CKAN pre-2.5: authz models were removed in migration 078 + if toolkit.check_ckan_version(max_version='2.4'): + sql += ''' + delete from user_object_role where id not in + (select user_object_role_id from package_role) and context = 'Package'; + delete from package_role where package_id in + (select id from package where state = 'to_delete'); + ''' + + sql += ''' delete from harvest_object_error where harvest_object_id in (select id from harvest_object where harvest_source_id = '{harvest_source_id}'); delete from harvest_object_extra where harvest_object_id in (select id from harvest_object where harvest_source_id = '{harvest_source_id}'); delete from harvest_object where harvest_source_id = '{harvest_source_id}'; delete from harvest_gather_error where harvest_job_id in (select id from harvest_job where source_id = '{harvest_source_id}'); delete from harvest_job where source_id = '{harvest_source_id}'; - delete from package_role where package_id in (select id from package where state = 'to_delete' ); - delete from user_object_role where id not in (select user_object_role_id from package_role) and context = 'Package'; delete from package_tag_revision where package_id in (select id from package where state = 'to_delete'); delete from member_revision where table_id in (select id from package where state = 'to_delete'); delete from package_extra_revision where package_id in (select id from package where state = 'to_delete');