-- Migration: Add new user Alesi Ravouvou to Karunaratne Lawyers
-- Date: 20251113
-- User: alesi@karunaratnelawyers.com.fj
-- Password: Alesi2025**

-- Add Alesi Ravouvou user for Karunaratne Lawyers
WITH
  alesi_user AS (
    SELECT '0194a8b2-4450-7123-8123-123456789ac3'::uuid AS user_id
  ),
  ins_user AS (
    INSERT INTO users (user_id, full_name, is_superadmin)
    VALUES ((SELECT user_id FROM alesi_user), 'Alesi Ravouvou', FALSE)
    ON CONFLICT DO NOTHING
  ),
  ins_email AS (
    INSERT INTO user_emails (user_id, email)
    SELECT user_id, 'alesi@karunaratnelawyers.com.fj' FROM alesi_user
    ON CONFLICT DO NOTHING
  ),
  ins_password AS (
    INSERT INTO user_passwords (user_id, password_hash, algo)
    SELECT user_id, '$2y$10$UlZM5Y.5W5NBqoPqJQn7BuTBkWR378CVDxGcMnkptkngIBq2t.gqu', 'bcrypt' FROM alesi_user
    ON CONFLICT DO NOTHING
  ),
  ins_membership AS (
    INSERT INTO user_org_memberships (user_id, org_id, role)
    SELECT user_id, '0194a8b2-5678-7123-8123-123456789abd'::uuid, 'Member' FROM alesi_user
    ON CONFLICT DO NOTHING
  )
SELECT 1;

-- Note: Alesi is added as a Member only (like Roma), not to any specific groups