-- Deployment 29: Developer / Test Admin account + View-as-User feature

-- 1. Add is_dev_admin flag to superadmins
ALTER TABLE `superadmins`
  ADD COLUMN IF NOT EXISTS `is_dev_admin` tinyint(1) NOT NULL DEFAULT 0
  COMMENT 'Dev/test admin: can impersonate any user for read-only preview';

-- 2. Create the dev admin account (change password after first login)
INSERT INTO `superadmins`
  (name, username, email, password_hash, is_active, is_dev_admin)
VALUES (
  'Dev Admin',
  'dev.admin',
  'dev@hammerheadstaffi.com',
  '$2y$12$DevAdminPlaceholderHashXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  1,
  1
)
ON DUPLICATE KEY UPDATE is_dev_admin = 1;

-- NOTE: Run this PHP snippet once on the server to set a real password hash:
-- echo password_hash('YourSecureDevPassword123!', PASSWORD_DEFAULT);
-- Then: UPDATE superadmins SET password_hash = '<output>' WHERE username = 'dev.admin';
