mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: add database constraint to enforce minimum username length (#19453)
Username length and format, via regex, are already enforced at the application layer, but we have some code paths with database queries where we could optimize away many of the DB query calls if we could be sure at the database level that the username is never an empty string. For example: https://github.com/coder/coder/pull/19395 --------- Signed-off-by: Callum Styan <callumstyan@gmail.com>
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE users
|
||||
DROP CONSTRAINT IF EXISTS users_username_min_length;
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE users
|
||||
ADD CONSTRAINT users_username_min_length
|
||||
CHECK (length(username) >= 1);
|
||||
Reference in New Issue
Block a user