Ajuste nas migrations

This commit is contained in:
Marcus Bohessef 2026-02-07 10:48:42 -03:00
parent 4253f49cbf
commit 40e7cce971

View file

@ -3,18 +3,20 @@
-- Increase status column length to support 'force_change_password' (21 chars)
ALTER TABLE users ALTER COLUMN status TYPE VARCHAR(50);
-- Update only the intended superadmin identifier to avoid unique constraint conflicts.
UPDATE users
SET
identifier = 'lol',
email = 'lol@gohorsejobs.com',
full_name = 'Dr. Horse Expert',
name = 'Dr. Horse Expert',
status = 'force_change_password',
-- Safely change the superadmin identifier ONLY if 'lol' is not already taken.
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM users WHERE identifier = 'lol') THEN
UPDATE users
SET identifier = 'lol',
updated_at = CURRENT_TIMESTAMP
WHERE identifier = 'superadmin';
WHERE identifier = 'superadmin';
ELSE
RAISE NOTICE 'Skipping identifier change: ''lol'' already exists';
END IF;
END$$;
-- If there is a separate user with email 'admin@gohorsejobs.com', update non-identifier fields only
-- Update non-identifier fields for the superadmin row (if present)
UPDATE users
SET
email = 'lol@gohorsejobs.com',
@ -22,4 +24,4 @@ SET
name = 'Dr. Horse Expert',
status = 'force_change_password',
updated_at = CURRENT_TIMESTAMP
WHERE email = 'admin@gohorsejobs.com' AND identifier <> 'lol';
WHERE identifier = 'superadmin' OR identifier = 'lol' OR email = 'admin@gohorsejobs.com';