Upgrade failure 1.19 to 1.20/1.21 at DB Migrate

Problem:
https://pastebin.com/FGpwUd8k

Debian Stretch , Puppet 5 , Foreman 1.19.1 to 1.20 and 1.21 (tried both ways) error after running apt upgrade when running DB Migrate due to duplicate entries in the database.

Expected outcome:

DB Migrate output without errors

Foreman and Proxy versions:

Foreman 1.19.1 to 1.20 and 1.21 reproducable

Foreman and Proxy plugin versions:

Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]
(for logs, surround with three back-ticks to get proper formatting, e.g.)

logs
https://pastebin.com/FGpwUd8k

This is Bug #24993: migration broken on nightly mysql - Foreman. do you have any plugins installed? we have not been able to reproduce the issue yet, if you have a snapshot or backup with the database prior to the upgrade that would be very helpful for debugging. if not, the linked issue contains a suggested workaround.