- Migration 032: add NOT EXISTS check to avoid duplicate key violation - CredentialsBootstrap: use NULLIF for updated_by UUID column, pass empty string instead of system_bootstrap
18 lines
794 B
SQL
18 lines
794 B
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.
|
|
-- Made idempotent: only runs if target identifier doesn't already exist.
|
|
|
|
-- Increase status column length to support 'force_change_password' (21 chars)
|
|
ALTER TABLE users ALTER COLUMN status TYPE VARCHAR(50);
|
|
|
|
-- Only update if 'lol' identifier doesn't already exist
|
|
UPDATE users
|
|
SET
|
|
identifier = 'lol',
|
|
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 email = 'admin@gohorsejobs.com')
|
|
AND NOT EXISTS (SELECT 1 FROM users WHERE identifier = 'lol');
|