CREATE TABLE IF NOT EXISTS payments ( id UUID DEFAULT gen_random_uuid() PRIMARY KEY, user_id UUID REFERENCES auth.users(id) NOT NULL, amount DECIMAL(10, 2) NOT NULL, status TEXT NOT NULL DEFAULT 'completed', -- completed, pending, failed plan_type TEXT NOT NULL, -- monthly, yearly, lifetime payment_method TEXT, -- credit_card, pix, etc created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL ); ALTER TABLE payments ENABLE ROW LEVEL SECURITY; CREATE POLICY "Users can view own payments" ON payments FOR SELECT USING (auth.uid() = user_id);