-- CostusWorx © 2026 — User tenant fix  2026-05-22
-- Run in phpMyAdmin on costusn8o8m0_retire_costusworx
-- ─────────────────────────────────────────────────────────────────────────────

-- Fix 1: stevep@growthhouse.co.za was created as superadmin with NULL tenant.
--         Assign to tenant 3 (Growthhouse) as admin so she can log in at
--         https://growthhouse.retire.costusworx.co.za/login
UPDATE users
   SET tenant_id = 3,
       role      = 'admin'
 WHERE id = 11
   AND email = 'stevep@growthhouse.co.za';

-- Fix 2: stevep@costusworx.co.za on tenant 4 (gh) is a duplicate caused by
--         the repeated creation attempts.  Decide: delete it, or keep it.
--         Uncomment to DELETE (recommended — tenant 4 is a duplicate):
-- DELETE FROM users   WHERE id = 12;
-- DELETE FROM tenants WHERE id = 4;

-- ─────────────────────────────────────────────────────────────────────────────
-- LOGIN REFERENCE after running Fix 1
-- ─────────────────────────────────────────────────────────────────────────────
--
-- User                            URL to log in                            Role
-- ─────────────────────────────── ──────────────────────────────────────── ─────
-- bruce@webnest.co.za             https://retire.retire.costusworx.co.za  super
--                                 OR https://retire.costusworx.co.za/admin
-- stevep@growthhouse.co.za        https://growthhouse.retire.costusworx.co.za  admin
-- gh.admin@costusworx.co.za       https://growthhouse.retire.costusworx.co.za  admin
-- gh.adviser@costusworx.co.za     https://growthhouse.retire.costusworx.co.za  adviser
-- gh.viewer@costusworx.co.za      https://growthhouse.retire.costusworx.co.za  viewer
-- stevep@costusworx.co.za         https://gh.retire.costusworx.co.za           super
--                                 (tenant 4 — duplicate, recommend deleting)
--
-- NOTE: passwords for gh.* users remain whatever was set when they were created.
-- ─────────────────────────────────────────────────────────────────────────────
