-- Fix any existing users with invalid permissions data
UPDATE users 
SET permissions = '{}'::jsonb 
WHERE permissions IS NULL OR permissions = 'null'::jsonb OR permissions = '[]'::jsonb;

-- Ensure all users have valid permissions
ALTER TABLE users ALTER COLUMN permissions SET DEFAULT '{}'::jsonb; 