Merge branch '105-clean-the-cleaner' of https://github.com/datawagovau/ckanext-harvest into datawagovau-105-clean-the-cleaner

This commit is contained in:
David Read 2015-10-09 15:00:56 +01:00
commit 372fc56c89
1 changed files with 10 additions and 2 deletions

View File

@ -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.99'):
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');