Files
LogiFlow/fix-duplicate-empty-email.sql
T
michaelschal c77ea88e9d Fix user creation errors by handling empty emails properly
Adjust user creation schema to allow null emails, update data handling to convert empty strings to null, and provide a SQL script to clean up existing duplicate empty email entries, resolving the `users_email_key` constraint violation.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/aiHrulP
2025-08-11 20:08:37 +00:00

28 lines
784 B
SQL

-- Fix duplicate empty email constraint issue in production
-- This script converts empty string emails to NULL to allow multiple users without email
-- Step 1: Update all empty string emails to NULL
UPDATE users
SET email = NULL
WHERE email = '' OR email IS NULL OR TRIM(email) = '';
-- Step 2: Verify the change
SELECT 'Users with NULL email:' as status, COUNT(*) as count
FROM users
WHERE email IS NULL;
-- Step 3: Verify no empty string emails remain
SELECT 'Users with empty string email:' as status, COUNT(*) as count
FROM users
WHERE email = '';
-- Step 4: Show sample of updated users
SELECT id, username,
CASE
WHEN email IS NULL THEN '[NULL]'
ELSE email
END as email_display,
role
FROM users
ORDER BY username
LIMIT 10;