How can I change a field cardinality? I have two content types: Person and Office with existing content. The Person content type has an entity reference field to Office nodes, which only allows a single reference. I need to change this to allow an unlimited number of Office nodes to be selected.

Drupal 8 prevents changing the cardinality of the field, and it gives the following error message.


  There is data for this field in the database. The field settings can no longer be changed.


At first, I thought I needed to write a migration, but they seem to be aimed at bringing data into a Drupal instance. Then, I read about writing update functions (also this documentation).

I discovered a migrate-plus plugin that adds a couple pages me to export the field storage settings, change the cardinality, and re-import the settings.
Given that I'm going from cardinality of 1 to unlimited, I could imagine this change wouldn't destroy data. And my empirical data suggests this is the case. I've now made this change via the migrate-plus screens as well as via configuration export and import and the data is still in the field.

Is this a safe operation, or should I write an update function?
There is data for this field in the database. The field settings can no longer be changed.


That message is misleading, it will actually not limit the ability to increase the cardinality. The only limitation is that it won't allow you to set the cardinality to a value lower than the highest amount of items you currently have.