Fix migration of attachments to use raw sql and not the models

The model Attachment changed a lot, the migration was broken. Have to use
raw SQL in it.

refs #454