Jacob_Anandam Jacob_Anandam - 1 year ago 136
MySQL Question

rails db:migrate error rails aborted

When I tried to rails db:migrate, I got the following error:

rails aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Duplicate entry 'MyString' for key 'index_users_on_email': CREATE UNIQUE INDEX `index_users_on_email` ON `users` (`email`)

Can someone help me on this, please? Thanks.

Answer Source

The error says that you're having a user record with a duplicate email called "MyString"(it exists in two records). Since the email has an unique index, it can't be duplicate.

Delete the user record with the duplicate email or update it to a unique email and then run

rake db:migrate