[OE-3987] migration foreign key bugfixes