mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
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
28 lines
784 B
SQL
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; |