superbasic question -- changing a user's username [RESOLVED]

Need help? Post your questions here.

Moderator: moderators

superbasic question -- changing a user's username [RESOLVED]

Postby supra92 » Mon Jul 15, 2013 11:10 pm

It seems implausible, but a search of the Help forum turned up zero posts/threads about what I would assume would be a fairly common task: changing a user's username once he/she has already been added. LOTS of questions about the admin/admin un/pw combo and about migrating users and database from install to install, but nothing about simply changing someone's name.

How exactly is this done? I've tried interacting directly with the database itself (via "db.view"), and issuing "update TABLENAME set username='newusername' where username='oldusername' " statements.... but I'm getting lots of foreign key errors when I try to do this. Trying to update the username in the USER table, it gripes about a FK in the USER_ROLE table.... but I get similar error when I try to update USER_ROLE too. Ditto for tables like Playlist, Custom_Avatar, etc -- key constraints preclude changing the username. Nor does there seem to be a way via SS's main interface itself. I try going to Settings, and then choosing a user from the dropdown..... but all I can change is the user's password, or delete the user entirely.

To answer what I'm anticipating to be a common response/question ("why don't you just delete the user and create a new one?")........... I don't want to do that because I'd like to preserve the user's info (Star ratings, reviews/comments, upload and download totals, etc.). Deleting and recreating loses all that information entirely. Plus, I don't want to have to ask the user for his/her password when recreating the account (or asking them to redo it themselves).

Renaming a user should be a simple process by the admin that should be transparent to the end user. And, I admit... it's somewhat surprising that there is not a central "User" table that contains ONLY user_id and username fields, with all other subsonic tables utilising the user_id, rather than the username itself. This is rather RDBMS/Normalisation 101 stuff, IMHO...

Anyone have any ideas?

Thanks,
Supra92
Last edited by supra92 on Fri Jul 19, 2013 11:14 pm, edited 1 time in total.
User avatar
supra92
 
Posts: 137
Joined: Sun Nov 19, 2006 12:17 am
Location: Central Texas

Re: superbasic question -- changing a user's username?

Postby stozher » Wed Jul 17, 2013 2:12 pm

Stop SS, open with text editor .../db/subsonic.script, find/replace... Create backup before edit!
http://music.stozher.com:8080/login.view?user=guest&password=
User avatar
stozher
 
Posts: 313
Joined: Tue Nov 16, 2010 10:56 am
Location: Sofia, Bulgaria

Re: superbasic question -- changing a user's username?

Postby supra92 » Fri Jul 19, 2013 11:14 pm

Hey Stozher,

Thanks for that -- worked like a charm! The idea of all that data being stored in a *text file*, and then written to the database every single time SS is restarted.... as opposed to simply being permanently in database.... didn't even occur to me. Strange, but hey... a simple "sed -i 's/oldname/newname/g' subsonic.script" and presto.

Only caveat I've seen thus far --- when you select Users to view the Upload/Download statistics/graphs, the old username appears there as well as the new one. That stuff is stored in the DB permanently, and so you have to actually go in and delete the oldname's row from that one DB table to get it to disappear from the charts. No biggie whatsoever.

Thanks again, and cheers,
Supra92
User avatar
supra92
 
Posts: 137
Joined: Sun Nov 19, 2006 12:17 am
Location: Central Texas


Return to Help

Who is online

Users browsing this forum: No registered users and 18 guests