How to Configure Dify Supabase Prevent Delete
You set up dify supabase prevent delete rules by creating a custom database role. Then you grant that role read and write rights while leaving out delete rights. Teams often link AI workflows to their database using the default admin password. This choice gives the AI agent way too much power over production tables. A bad prompt or agent loop can wipe out customer rows in seconds. How to set up dify supabase prevent delete at the role level Every Supabase project starts with a default postgre
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up dify supabase prevent delete rules by creating a custom database role. Then you grant that role read and write rights while leaving out delete rights. Teams often link AI workflows to their database using the default admin password. This choice gives the AI agent way too much power over production tables. A bad prompt or agent loop can wipe out customer rows in seconds.
How to set up dify supabase prevent delete at the role level
Every Supabase project starts with a default postgres role that holds admin privileges. The platform does not grant full superuser status because that allows destructive actions. Instead, it gives this default role extra rights for most admin tasks. You set the password for this default role when you create the project. Queries you run in the web dashboard also run as this default admin role.
Supabase docs state you should never give this main password to outside apps. Instead, you should make a fresh database user for each outside service. For an AI tool like Dify, this rule is your first safety step. You create a dedicated role just for your AI workflows and tools. Then you grant that role permission to read tables and insert or update rows. You simply skip granting permission to delete rows or drop tables.
Supabase also creates built-in roles like the anon role for public API requests. If your Dify workflow calls the database through the API, row-level security applies. You can write policies that allow select and insert actions for that role. When you leave out a policy for delete actions, the database blocks row removal. Both direct database users and API roles help stop accidental data loss.
What native database roles solve and what they miss
Custom roles and table grants are great for basic access control. They decide who can log in and which tables that user can touch. When a Dify agent tries to run a delete statement, Postgres says no. This setup stops whole classes of mistakes before they hurt your database.
Still, static database roles only check permissions at a broad table level. They cannot inspect what individual statements or requests do in flight. For example, a role with update rights can still ruin your data. An agent might run an update statement without a filter and blank out rows. To the database, that is a valid update rather than a delete action.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static roles also do not solve sensitive data exposure during normal read queries. If Dify has read access to a customer table, it pulls every column. You might need data masking that rewrites emails, phone numbers, or card numbers. You might also want human approval before an agent runs a risky update. Native database roles alone cannot pause a query to ask a human first. They also do not tie database queries back to a specific user identity.
Why AI workflows need statement-level controls
AI agents build and run queries based on user prompts and model outputs. Unlike standard app code, an agent might change its query pattern every time. Giving an AI app a static password means every prompt shares the same rights. If one user tricks the prompt, the agent acts with full role permissions.
Teams need a way to inspect each query right before it runs. This check lets you block dangerous updates alongside direct delete statements. It also lets you mask national IDs or card numbers in query results. Combining restricted database roles with runtime checks keeps your data safe during AI runs.
Add query and result controls beside Postgres
Grants and pools govern who logs into PostgreSQL. Yet every query in an open session still runs with that role's full scope. In practice, hoop.dev runs beside your database as a sidecar for your Postgres. It reads plain and prepared queries on the wire with no change to your users or drivers.
When a tool or agent sends SQL, hoop.dev Postgres controls check each statement against your deny rules. An AI Analyzer you configure can also score intent or hold a risky query for human review. Matched sensitive columns in result rows are masked in memory before they reach the caller. Each query and decision is logged per listener, which generates evidence for SOC 2, HIPAA, and GDPR audits. View the binary on GitHub.
Frequently asked questions
Why should I not use the default postgres role for Dify?
The default postgres role has admin privileges across your database project. Supabase warns against sharing this password with outside services and suggests making separate users.
Does stopping delete permissions also stop bad update queries?
No, blocking delete permissions only stops row removal statements. An AI agent with update permissions can still overwrite existing values with blank data.
How does data masking help when Dify reads from Supabase?
Masking rewrites matched fields like emails, phone numbers, and card numbers in query results. This keeps sensitive customer details out of AI prompts and model logs.
Related guides
In this post