Relative Content

Tag Archive for databasepostgresqlsupabase

Limiting insertion into Supabase table with same values using RLS policies

I have a payments table which has a foreign key to a table called bundles, the payments table has the methods is_successful, bundle_id and user_id (the rest are irrelevant).
I need to not allow a user to pay for the same bundle twice (or a disabled bundle), this means not allow them to insert into payments table if it already has a row with their auth.uid() and the same bundle_id and is_successful set to true.