Fixed migration of allowed accounts, applications, contacts and template

Refs #1555