Updates to migrations 12 & 40

- Fix an issue where existing entries are not migrated when the
migration schema is upgraded (012_Migration_schema_change)
- Prevent potential conflict with a variable name in
040_Remove_updates_settings