Adds index on document ID for attachments. Fixes #338