-- Fix the CompanyRole field for admin@demo.com
-- Run this against PowderCoatingDb

-- First, let's see the current value
SELECT
    Email,
    CompanyRole,
    LEN(CompanyRole) as RoleLength,
    CAST(CompanyRole AS VARBINARY(MAX)) as RoleBytes
FROM AspNetUsers
WHERE Email = 'admin@demo.com';

-- Update to a clean value
UPDATE AspNetUsers
SET CompanyRole = 'CompanyAdmin',
    SecurityStamp = NEWID(),
    ConcurrencyStamp = NEWID()
WHERE Email = 'admin@demo.com';

-- Verify the fix
SELECT
    Email,
    CompanyRole,
    CompanyId,
    FirstName,
    LastName
FROM AspNetUsers
WHERE Email = 'admin@demo.com';

PRINT 'CompanyRole has been reset to CompanyAdmin.';
