Ajuste nas migrations
This commit is contained in:
parent
4253f49cbf
commit
40e7cce971
1 changed files with 14 additions and 12 deletions
|
|
@ -3,18 +3,20 @@
|
||||||
|
|
||||||
-- Increase status column length to support 'force_change_password' (21 chars)
|
-- Increase status column length to support 'force_change_password' (21 chars)
|
||||||
ALTER TABLE users ALTER COLUMN status TYPE VARCHAR(50);
|
ALTER TABLE users ALTER COLUMN status TYPE VARCHAR(50);
|
||||||
-- Update only the intended superadmin identifier to avoid unique constraint conflicts.
|
-- 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
|
UPDATE users
|
||||||
SET
|
SET identifier = 'lol',
|
||||||
identifier = 'lol',
|
|
||||||
email = 'lol@gohorsejobs.com',
|
|
||||||
full_name = 'Dr. Horse Expert',
|
|
||||||
name = 'Dr. Horse Expert',
|
|
||||||
status = 'force_change_password',
|
|
||||||
updated_at = CURRENT_TIMESTAMP
|
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
|
UPDATE users
|
||||||
SET
|
SET
|
||||||
email = 'lol@gohorsejobs.com',
|
email = 'lol@gohorsejobs.com',
|
||||||
|
|
@ -22,4 +24,4 @@ SET
|
||||||
name = 'Dr. Horse Expert',
|
name = 'Dr. Horse Expert',
|
||||||
status = 'force_change_password',
|
status = 'force_change_password',
|
||||||
updated_at = CURRENT_TIMESTAMP
|
updated_at = CURRENT_TIMESTAMP
|
||||||
WHERE email = 'admin@gohorsejobs.com' AND identifier <> 'lol';
|
WHERE identifier = 'superadmin' OR identifier = 'lol' OR email = 'admin@gohorsejobs.com';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue