From 1905caa961b9b90f4dfd03301b62609e607f3fbb Mon Sep 17 00:00:00 2001 From: florianm Date: Wed, 19 Aug 2015 10:25:20 +0800 Subject: [PATCH] upgrade harvest_source_clear to not delete from authz models removed in migration 078 --- ckanext/harvest/logic/action/update.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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');