Do not delete indexes if they are needed for foreign keys
Before
When changing a custom field from searchable to not searchable, CiviCRM tries to remove the index. This causes a fatal error when the column is also a foreign key to another table because the index is needed for the foreign key.
After
We ensure that the column is not an FK before removing the index
Technical details
I added a test to CustomFieldTest which exercises this functionality