Now everyone can change their username if they want. I delayed implementing this because it needed to redirect old URLs to the new blog address, and I thought it'd be more difficult. It was actually really easy.
| prev_alias | new_alias |
The logic upon updating a name:
# Remove any existing redirects with the new blog name DELETE FROM collectionredirects WHERE prev_alias = 'blog2' # Redirect all redirects to the previous name to the new one UPDATE collectionredirects SET new_alias = 'blog2' WHERE new_alias = 'blog1' # Redirect previous name to the new one INSERT INTO collectionredirects (prev_alias, new_alias) VALUES ('blog1', 'blog2')
Then the application simply had to look things up and send the right HTTP responses. Sweet! A web that doesn't break when you change some names.
The problem now is notifying other browser sessions and (in the future) other clients about username changes. There's no real straightforward way to do this with adding extra backend bloat, so I'm leaving this alone for now until the issue arises.