12 lines
408 B
SQL
12 lines
408 B
SQL
-- T0219: Add Profile Slug Generation
|
|
-- Add slug column to users table for URL-friendly profile URLs
|
|
|
|
ALTER TABLE users ADD COLUMN IF NOT EXISTS slug VARCHAR(255);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_users_slug ON users(slug);
|
|
|
|
-- Populate existing users with slugs from their usernames
|
|
UPDATE users
|
|
SET slug = LOWER(REGEXP_REPLACE(username, '[^a-zA-Z0-9]', '-', 'g'))
|
|
WHERE slug IS NULL OR slug = '';
|
|
|