Patch `CustomForeignKeyField.do_related_class` method for migrations