Drupal version 8.
The issue is that adding a base field to a custom entity type in code would result in an issue of unique constraint violation as there does not seem to be a way to preset the value to the newly added field.
setInitialValue()setInitialValue()
would set the same value for all the existing entities triggering a constraint violation.
setInitialValueFromField()setInitialValueFromField()
would not do any good as it would only allow fetching value from fields of same type. Otherwise it would be possible to utilise the value from an idID field and then replace those initial values with something more suitable.
Is there any meaningful way for doing that?