Resolved (sort of) in cset:489007a10bb9. This was a migration issue.
Tracked this down to fact that on ckan.net we have:
"package_resource_revision_pkey" PRIMARY KEY, btree (id)
When it should be:
"package_resource_revision_pkey" PRIMARY KEY, btree (id, revision_id)
Looking in browser:ckan/migration/versions/012_add_resources.py find:
Column('revision_id', UnicodeText, ForeignKey('revision.id')),
#NB revision_id should have been primary_key too (joint with id)
How come this was not corrected here or at least noted for upgrade of ckan.net???
I have now fixed this so that others doing migration (at least with v1.0) will end up with correct code.
I have also fixed issue on ckan.net by manual sql!