UN-delete user manually? (General)

by Nico Hoffmann @, (163 days ago)

Hello,

I am currently cleaning up my user database, i.e. I deleted lots of dead accounts.
Unfortunately, I deleted a few accounts wrongly :-(

The last backup is some weeks old, so by replaying it I would lose content.

I know which users were deleted wrongly, and I have all their data in my backup.
Therefore it should be possible to undelete my mistake.

I looked into the database and noticed two locations where some changes would have to be done:

First, the userdata table of course. I have to extract the userdata table from the dump, this can be done like described here: https://stackoverflow.com/questions/1013852/can-i-restore-a-single-table-from-a-full-mysql-mysqldump-file
From this table I could extract the ingredients for a SQL insert statement:


INSERT INTO userdata (user_id, user_type, user_name, user_real_name, ...) VALUES (123, 0, 'name_of_deleted_user', 'real name', ...);


and manually manipulate the userdata table. In total, I counted 38 single data items for one entry in the userdata table.
After that, the userdata table should be OK again.


Second, the 'entries' table has one data record for each posting. For the deleted users, the user_id field seems set to '0', and this should be set to the original value. Something like


UPDATE entries SET user_id = 123 WHERE name = 'name_of_deleted_user' 


should do the trick.

Is that correct or is there missing anything?

(disclaimer: code untested, manipulating tables in that way can damage a database completely, so do NOT just copy&paste it!)

Nico


Complete thread:

 RSS Feed of thread