-- Ensure id has a default and role has a default
ALTER TABLE profiles ALTER COLUMN id SET DEFAULT gen_random_uuid();
ALTER TABLE profiles ALTER COLUMN role SET DEFAULT 'user';

-- Drop the foreign key constraint if it exists (it was referencing auth.users)
-- Based on previous check it might already be gone, but let's be sure
DO $$ 
BEGIN
  IF EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'profiles_id_fkey') THEN
    ALTER TABLE profiles DROP CONSTRAINT profiles_id_fkey;
  END IF;
END $$;
