How to Configure Dify CockroachDB Prevent Delete
You set up dify cockroachdb prevent delete rules by revoking drop and delete privileges. You assign a limited database role to your AI app user account. Many teams start by giving their AI workflows a broad admin database account. That broad role lets a confused model wipe out production tables by mistake. Restricting the database user stops the app from running destructive queries. How to set up dify cockroachdb prevent delete roles Dify lets you build AI workflows that query external SQL da
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 cockroachdb prevent delete rules by revoking drop and delete privileges. You assign a limited database role to your AI app user account. Many teams start by giving their AI workflows a broad admin database account. That broad role lets a confused model wipe out production tables by mistake. Restricting the database user stops the app from running destructive queries.
How to set up dify cockroachdb prevent delete roles
Dify lets you build AI workflows that query external SQL databases. Your workflow connects to CockroachDB using a standard database user and password. To block deletions, you must change how that database user works. First, an admin logs in to the CockroachDB cluster with full rights. The admin creates a dedicated role just for the AI workflow. Next, the admin grants only read, insert, and update rights to this role. The admin leaves out the delete, truncate, and drop table rights.
Then, the admin assigns this strict role to the Dify database user. You put those user credentials into your Dify tool settings. When the AI agent runs, it sends SQL queries using that specific user. CockroachDB checks the role rules before it runs any query. If the AI tries to delete a row, the database blocks the command. The database returns a permission error back to the Dify workflow. Your core records stay safe even when a prompt goes wrong.
Why static database roles leave an operational gap
Native database roles work well for basic table rules. They decide which user can log in and which actions are valid. Still, static roles cannot inspect the context of a single query in flight. Sometimes an AI workflow needs to delete temporary staging rows during a task. If you grant delete rights for one table, the agent can wipe every row by default. Native roles cannot tell a safe single-row delete from a full table wipe.
Also, static roles do not stop an AI from reading private data fields. A read-only query can still pull emails, phone numbers, or card numbers. The database sends those raw fields right back to the language model. Static user accounts also force teams to store database passwords inside Dify settings. If someone copies those credentials, they can run queries from outside your app. Teams need a way to inspect every SQL statement before it runs.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Managing query risks in AI workflows
Safe AI database workflows need controls that act on each query. You should separate read tasks from write tasks inside your Dify workflows. Use a strict read-only database user for all search and chat tools. Create a separate database user for workflows that must write new records. Keep your sensitive tables in a separate schema with zero AI permissions.
You should also watch query logs to spot bad AI prompts early. Look for failed delete attempts or large select queries in your database logs. When you see repeated permission errors, fix the prompt in your Dify app. Masking tools can also rewrite emails and national IDs in query results. This keeps private user details out of external model logs.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Can Dify block SQL delete queries on its own?
No, Dify only builds and sends the SQL query from the model. You can add rules in the prompt, but models often ignore text rules. You must enforce delete blocks at the database or query level.
What happens in Dify when CockroachDB blocks a delete query?
CockroachDB stops the query and returns a standard permission error message. The Dify node catches this error and stops that branch of the workflow. You can set up Dify to show a safe fallback message to users.
How do I let Dify archive data without using delete commands?
You can use soft deletes instead of removing rows from the table. Add a status column to your table and grant update rights to Dify. The AI workflow updates the row status to inactive while keeping the record.
Related guides
In this post