-- Create profiles table CREATE TABLE IF NOT EXISTS profiles ( id UUID PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE, full_name TEXT, email TEXT, avatar_url TEXT, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); -- Enable RLS ALTER TABLE profiles ENABLE ROW LEVEL SECURITY; -- Create policies CREATE POLICY "Users can view their own profile" ON profiles FOR SELECT USING (auth.uid() = id); CREATE POLICY "Users can update their own profile" ON profiles FOR UPDATE USING (auth.uid() = id); CREATE POLICY "Users can insert their own profile" ON profiles FOR INSERT WITH CHECK (auth.uid() = id); ALTER TABLE profiles DROP CONSTRAINT IF EXISTS profiles_username_key; -- ALTER TABLE profiles -- ADD CONSTRAINT profiles_username_key UNIQUE (username);