Update Field Name

You are doing the appropriate update.

But the error message says it all.

You have a unique index on the username field. When you rename username to email, you get null as the value of the username (because the field does not exist anymore). Hence, you get duplicate key error.

For you update to work, you must remove the unique index username_1. You most likely need to create one for email.

1 Like