www_site/services/api/migrations/006_usernames.sql

8 lines
240 B
MySQL
Raw Normal View History

ALTER TABLE users ADD COLUMN IF NOT EXISTS username TEXT;
UPDATE users
SET username = 'user_' || replace(left(id::text, 18), '-', '')
WHERE username IS NULL;
CREATE UNIQUE INDEX IF NOT EXISTS users_username_unique_idx ON users(username);