{"action":"created","issue":{"url":"https://api.github.com/repos/ckan/ckanext-harvest/issues/152","labels_url":"https://api.github.com/repos/ckan/ckanext-harvest/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/ckan/ckanext-harvest/issues/152/comments","events_url":"https://api.github.com/repos/ckan/ckanext-harvest/issues/152/events","html_url":"https://github.com/ckan/ckanext-harvest/pull/152","id":101794206,"number":152,"title":"Fix #105 by adapting harvest_source_clear to removal of authz models","user":{"login":"florianm","id":762815,"avatar_url":"https://avatars.githubusercontent.com/u/762815?v=3","gravatar_id":"","url":"https://api.github.com/users/florianm","html_url":"https://github.com/florianm","followers_url":"https://api.github.com/users/florianm/followers","following_url":"https://api.github.com/users/florianm/following{/other_user}","gists_url":"https://api.github.com/users/florianm/gists{/gist_id}","starred_url":"https://api.github.com/users/florianm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/florianm/subscriptions","organizations_url":"https://api.github.com/users/florianm/orgs","repos_url":"https://api.github.com/users/florianm/repos","events_url":"https://api.github.com/users/florianm/events{/privacy}","received_events_url":"https://api.github.com/users/florianm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"amercader","id":200230,"avatar_url":"https://avatars.githubusercontent.com/u/200230?v=3","gravatar_id":"","url":"https://api.github.com/users/amercader","html_url":"https://github.com/amercader","followers_url":"https://api.github.com/users/amercader/followers","following_url":"https://api.github.com/users/amercader/following{/other_user}","gists_url":"https://api.github.com/users/amercader/gists{/gist_id}","starred_url":"https://api.github.com/users/amercader/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amercader/subscriptions","organizations_url":"https://api.github.com/users/amercader/orgs","repos_url":"https://api.github.com/users/amercader/repos","events_url":"https://api.github.com/users/amercader/events{/privacy}","received_events_url":"https://api.github.com/users/amercader/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-08-19T02:39:27Z","updated_at":"2015-10-09T14:08:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ckan/ckanext-harvest/pulls/152","html_url":"https://github.com/ckan/ckanext-harvest/pull/152","diff_url":"https://github.com/ckan/ckanext-harvest/pull/152.diff","patch_url":"https://github.com/ckan/ckanext-harvest/pull/152.patch"},"body":"## TL;DR\r\nFix #105 by upgrading harvest_source_clear to not delete from authz models removed in migration 078 for CKAN versions > 2.4.\r\n\r\n## Details\r\nMigration [078](https://github.com/ckan/ckan/blob/63e3bc9186f02a4bf1cce24b4c5d937e696c04c3/ckan/migration/versions/078_remove_old_authz_model.py) removes the legacy authz models, including `package_role` and `user_object_role`.\r\nThese two models are deleted from in `harvest_source_clear`. This PR moves the SQL queries to delete from the two corresponding tables to a conditional block which only runs for CKAN pre-2.5.\r\n\r\n## Assumptions\r\n* Migration 078 applies to versions >= 2.5. Maintainers: is that correct?\r\n* The models `package_role` and `user_obkect_role` exist in CKAN up to version 2.4.\r\n\r\n## Effect\r\n* Harvest > View a harvesting source > Admin > Clear will work again.\r\n* Works in CKAN 2.5, but untested in CKAN < 2.5"},"comment":{"url":"https://api.github.com/repos/ckan/ckanext-harvest/issues/comments/146881607","html_url":"https://github.com/ckan/ckanext-harvest/pull/152#issuecomment-146881607","issue_url":"https://api.github.com/repos/ckan/ckanext-harvest/issues/152","id":146881607,"user":{"login":"davidread","id":307612,"avatar_url":"https://avatars.githubusercontent.com/u/307612?v=3","gravatar_id":"","url":"https://api.github.com/users/davidread","html_url":"https://github.com/davidread","followers_url":"https://api.github.com/users/davidread/followers","following_url":"https://api.github.com/users/davidread/following{/other_user}","gists_url":"https://api.github.com/users/davidread/gists{/gist_id}","starred_url":"https://api.github.com/users/davidread/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidread/subscriptions","organizations_url":"https://api.github.com/users/davidread/orgs","repos_url":"https://api.github.com/users/davidread/repos","events_url":"https://api.github.com/users/davidread/events{/privacy}","received_events_url":"https://api.github.com/users/davidread/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T14:08:10Z","updated_at":"2015-10-09T14:08:10Z","body":"I'm keen to merge this, but one more thing: why did you swap over the order of deleting user_object_role and package_role? There is a foreign key relation between them, so in the absence of testing it on an old ckan, it's probably safest to keep it in the order it was, don't you think?\r\n\r\nHere's the constraint and the way I see it you need to delete the package_role before any user_object_role that it references:\r\n\r\n    package_role_table = Table('package_role', meta.metadata,\r\n           Column('user_object_role_id', types.UnicodeText, ForeignKey('user_object_role.id'), primary_key=True),"}}