How to check what prevents rake migrate?

You should NOT drop the index!

You just need to delete the duplicate record.

Find the second record with user_id= -4 and category_id 9 and delete it using it’s id

This is a risky operation so first check with:

SELECT FROM category_users WHERE id = <the second id>;

to ensure it just brings back one record, then:

DELETE FROM category_users WHERE id = <the second id>;

Can you recall what if any changes you made wrt to the bot?