Deleted user with rails console u.delete -> email still "taken"

So the old e-mail I had assigned to my admin account no longer existed after changing domains, so I wanted to change the e-mail address but couldn’t because it requires a verification to the old e-mail.

Long story short I did a bunch of things, changed some e-mails, created another admin account, and deleted the second admin account using the console, but now I can’t reuse the email I had assigned to the second admin account.

Not sure whether to put this under support or bugs.
To be honest I have a backup I could try to use, but before doing that, is this a bug? Any way to fix this without a full reset / restoring from a backup?

install the data explorer plugin and then you can check which table still has your email that you want to delete

You’d still need to know which table(s) to look/delete from, unless you’re proposing that I should manually create 100+ uniquely crafted queries for 100+ different tables with different schemas.

Would appreciate if someone could recategorize this post under bugs.

It seems likely that this is not a bug. It depends how you deleted the user from the console.

From the console, try searching for:

UserEmail.where(email: '<your_deleted_users_email>')

If that gives you a result, try searching for the user with the user_id that was returned:

User.find_by(id: <email_record_id>)

My guess is that no user will be returned because the email belonged to the user you deleted. If that is the case, it should be safe to call destroy! on the email record. Before trying this, be sure that you have an up-to-date backup of your site.

If the email does belong to an existing user, do not delete the email record.

2 Likes

To delete a user from the console, use UserDestroyer. See Deleting Users in rails console - #2 by jomaxro.

Note to self, turn that into #howto:faq

4 Likes