feat(chat): add username to users

And use it instead of hacky email transformation.
This commit is contained in:
2025-02-13 23:13:36 +00:00
parent 489be57db7
commit 24b609ec3a
3 changed files with 29 additions and 7 deletions

View File

@@ -0,0 +1,25 @@
defmodule Slax.Repo.Migrations.AlterUsersAddUsername do
use Ecto.Migration
def change do
alter table(:users) do
add :username, :citext
end
query = """
update
users
set
username = initcap(substring(email from '^[^@]+'))
;
"""
execute query, ""
alter table(:users) do
modify :username, :citext, null: false, from: {:citext, null: true}
end
create unique_index(:users, :username)
end
end