# Recent migration to discourse caused usernames to change!

**URL:** https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067
**Category:** Support
**Created:** [October 2, 2024, 7:12pm UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067 "2024-10-02T19:12:55Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [October 2, 2024, 7:12pm UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/1 "2024-10-02T19:12:55Z")

</div>

I recently moved a site to Discourse. what i didn’t realise was many users usernames got changed and the new usernames seem to use a part of their email address. I have never seen usernames change during previous migrations. how can i revert this?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 3, 2024, 8:04am UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/2 "2024-10-03T08:04:21Z")

</div>

If you’ve gone live then it’ll be difficult to change things, though the original username should be in a user custom field. You really want to solve these problems in the testing phase.

Unless the migration script is broken, the reason that usernames are changed is that they are incompatible with the discourse username format.

What are some usernames that were changed? What did you migrate from?

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [October 4, 2024, 3:10pm UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/3 "2024-10-04T15:10:13Z")

</div>

Thank you for your reply Jay. We had to put the site on maintenance mode to make these corrections. it was weird that the username and name columns were changed. we are seeing how we can swap them. this is very confusing…

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 4, 2024, 6:15pm UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/4 "2024-10-04T18:15:22Z")

</div>

You can look at `UserCustomField.where(user_id: some_id)` to see what custom fields exist for that user, which should include their original username.

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [October 5, 2024, 8:23am UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/5 "2024-10-05T08:23:48Z")

</div>

We were able to swap. But after swapping the profiles won’t open! It’s says oops page not found.

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [October 5, 2024, 2:42pm UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/6 "2024-10-05T14:42:03Z")

</div>

Just to double check, you refreshed your page after remapping usernames, right? Discourse will still use old name client-side until you reload, so if you remapped names and didn’t reload, it’d try to open user profiles that no longer exist.

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [October 5, 2024, 3:17pm UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/7 "2024-10-05T15:17:22Z")

</div>

Thank you. We will check for that.  
Also, I don’t understand how it decides to automatically assign first half of the email address.

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [October 7, 2024, 6:11am UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/8 "2024-10-07T06:11:40Z")

</div>

The precious platform allowed users to create profile names using spaces and special characters, and it used userID for URL.

Can we use userID on URL and allow migration of profile names with spaces and special characters as is?

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [October 7, 2024, 6:56am UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/9 "2024-10-07T06:56:24Z")

</div>

We saw that sims usernames and names were the same.  
We realised some names now contain spaces.

If we swap username and name sections, then discourse might assign half email ID as username for the ones that don’t comply with profile name guidelines.

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [October 7, 2024, 6:57am UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/10 "2024-10-07T06:57:27Z")

</div>

And why would discourse use email addresses in the first place? Security risk

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 7, 2024, 2:23pm UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/11 "2024-10-07T14:23:57Z")

</div>

> [@hmmmnotsure](#):
>
> Can we use userID on URL and allow migration of profile names with spaces and special characters as is?

No. Discourse does not allow spaces or (most) special characters in usernames. That’s why they got re-written.

I don’t understand what you’re saying about URL.

> [@hmmmnotsure](#):
>
> And why would discourse use email addresses in the first place? Security risk

It has to use something to generate a username.

It does this:

```plaintext
UserNameSuggester.suggest(
        opts[:username].presence || opts[:name].presence || opts[:email],

```

So if you don’t have a username or a name it falls back to using the first part of the email address.

---

<div class="post-metadata">

### Author: ![hmmmnotsure](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hmmmnotsure/32/472794_2.png) [@hmmmnotsure](https://meta.discourse.org/u/hmmmnotsure)
#### Post date: [October 7, 2024, 5:15pm UTC](https://meta.discourse.org/t/recent-migration-to-discourse-caused-usernames-to-change/329067/12 "2024-10-07T17:15:53Z")

</div>

> [@pfaffman](#):
>
> ```plaintext
> UserNameSuggester.suggest(
> opts[:username].presence || opts[:name].presence || opts[:email],
> 
> ```

So we can change it to something else? or remove email ID as an option?
