diff --git a/db/migrations/000004_fix_usernames.sql b/db/migrations/000004_fix_usernames.sql new file mode 100644 index 0000000..58b13e6 --- /dev/null +++ b/db/migrations/000004_fix_usernames.sql @@ -0,0 +1,3 @@ +-- +goose Up +UPDATE users +SET username = LOWER(username); \ No newline at end of file diff --git a/internal/db/psql/user.go b/internal/db/psql/user.go index 33a8cf9..b80ddad 100644 --- a/internal/db/psql/user.go +++ b/internal/db/psql/user.go @@ -120,7 +120,7 @@ func (d *Psql) UpdateUser(ctx context.Context, opts db.UpdateUserOpts) error { } err = qtx.UpdateUserUsername(ctx, repository.UpdateUserUsernameParams{ ID: opts.ID, - Username: opts.Username, + Username: strings.ToLower(opts.Username), }) if err != nil { return fmt.Errorf("UpdateUser: UpdateUserUsername: %w", err)