gohorsejobs/backend/migrations/032_update_superadmin_lol.sql
2026-02-07 10:48:42 -03:00

27 lines
1 KiB
SQL

-- Migration: Update Super Admin to 'lol' and force password reset
-- Description: Updates the superadmin identifier, email, name, and sets status to enforce password change.
-- Increase status column length to support 'force_change_password' (21 chars)
ALTER TABLE users ALTER COLUMN status TYPE VARCHAR(50);
-- 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';
ELSE
RAISE NOTICE 'Skipping identifier change: ''lol'' already exists';
END IF;
END$$;
-- Update non-identifier fields for the superadmin row (if present)
UPDATE users
SET
email = 'lol@gohorsejobs.com',
full_name = 'Dr. Horse Expert',
name = 'Dr. Horse Expert',
status = 'force_change_password',
updated_at = CURRENT_TIMESTAMP
WHERE identifier = 'superadmin' OR identifier = 'lol' OR email = 'admin@gohorsejobs.com';