ALTER TABLE users ADD COLUMN IF NOT EXISTS username TEXT;

-- Backfill existing users with their email as username to satisfy NOT NULL constraint
UPDATE users SET username = email WHERE username IS NULL;

ALTER TABLE users ALTER COLUMN username SET NOT NULL;
ALTER TABLE users ADD CONSTRAINT users_username_key UNIQUE (username);
