Rename a content type's "in" validation?

I have several content types that have a “Background color” field with most of those having in: ['white', 'black', 'blue'] validations in a dropdown. I want to change the word ‘blue’ to ‘primary’ in a migration script, in case the “primary color” eventually changes from blue (I’m adding multiple themes to the app, so the primary color will indeed change depending on the selected theme).
Problem is I have 50,000 entries using ‘blue’ as their selected color validation, and running that script will wipe all of those fields clean and I’d have to go in manually to re-set every single field back to ‘primary.’
Is there a way to simply rename a validation ‘in’ array element using a migration script? Is this possible through the CMA?

I’m no expert in this, I have only made a single migration script so far :slight_smile:

I think the easiest (and safest) way to achieve the switch from Background color: Blue to Background color: Primary is to create a migration script that does the following:

  1. Create a new field “Background color 2”
  2. Set up your new validation rules for “Background color 2”
  3. Go through all entries and for each field “Background color” add the corresponding value in “Background color 2” (“blue” is for example replaced with “primary”)

When you have checked that the transformation was succesful, change your application to use the field “Background color 2” instead of “Background color”.

Disable the field “Background color” and eventually delete it when you don’t need it anymore.

See the documentation for “Migrating the content” for more details:

Why not adding ‘primary’ to the current validation array, run the script, then removing ‘blue’?