How to Configure Devin SQL Server Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up devin sql server prevent delete rules, restrict the agent's database user permissions. You must replace broad write roles with specific permissions that block delete statements. Teams often connect AI agents using standard admin accounts to move fast. Those broad roles let an autonomous agent remove rows or drop entire tables by mistake. A safer setup uses strict database roles that allow updates and inserts without delete rights. How to set up devin sql server prevent delete rules

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.

To set up devin sql server prevent delete rules, restrict the agent's database user permissions. You must replace broad write roles with specific permissions that block delete statements. Teams often connect AI agents using standard admin accounts to move fast. Those broad roles let an autonomous agent remove rows or drop entire tables by mistake. A safer setup uses strict database roles that allow updates and inserts without delete rights.

How to set up devin sql server prevent delete rules

First, you need to set up a dedicated identity for the AI agent. In SQL Server, a database user represents a login when it enters a database. If the agent needs many databases on an instance, create a login in master. Then map a SQL user to that login inside each target database. If the agent only needs one database, you can use a contained database user. This user holds a password and does not tie to a login in master. An admin must enable contained databases on the server and database first.

Next, you must check the fixed database roles assigned to that user. You cannot change the permissions assigned to fixed database roles in SQL Server. For example, the db_owner role can run all maintenance tasks and drop the database. The db_datawriter role can add, delete, or change data across all user tables. Because db_datawriter bundles inserts, updates, and deletes together, do not give it to Devin.

Instead, start by adding the user to the db_datareader fixed role. Members of db_datareader can read all data from all user tables and views. If the agent only needs to read data, also assign the db_denydatawriter role. Members of db_denydatawriter cannot add, change, or delete any data in user tables. If the agent must write data, create a custom role that grants insert and update. Then apply an explicit deny rule for the delete permission across your schemas. In SQL Server, an explicit deny rule overrides any grant rule on that table.

Why native roles are only half the fix

Native SQL Server roles decide who logs in and which general commands are valid. They work well when an agent always needs the exact same level of access. Still, static database permissions cannot tell good queries from bad ones in flight.

If an agent has update permissions, it still carries major risk for your data. An agent blocked from deleting rows can still run an update without a filter. That single bad update can overwrite every row in a user table with blank values by default. To the database engine, a destructive mass update looks just like a safe single-row update.

SQL Injection Prevention + Kubernetes API Server Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also do not stop sensitive data from leaving the database during reads. A member of db_datareader can read every column in every user table and view by default. That includes tables holding emails, phone numbers, card numbers, and national IDs. Also, native roles require you to store static passwords inside the agent's workspace. If you want a human to check risky write queries first, roles cannot pause execution.

Managing custom roles across many tables

Maintaining custom roles also adds extra work as your database schema grows over time. Every time your team adds a new schema, admins must check the deny rules. If someone puts the agent back into db_datawriter during a fix, delete protection disappears. Teams need a way to inspect individual queries and mask sensitive fields in results.

Add runtime guardrails beside SQL Server

Role grants and network rules are needed setup for SQL Server. Still, an allowed user or agent tool can send a bad delete or read raw customer fields over a valid session. In practice, hoop.dev runs beside the database as a sidecar for your SQL Server and checks TDS traffic without changing how clients log in.

With hoop.dev SQL Server controls, rules refuse banned statements before they run and can hold risky queries for human review. Matched sensitive values in supported result columns are masked before they reach the client. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for HIPAA, PCI DSS, SOX, and GDPR audits. See the source on GitHub.

Frequently asked questions

Can I change the db_datawriter role to block delete commands?

No, you cannot change the permissions assigned to fixed database roles in SQL Server. The db_datawriter role always allows adding, changing, and deleting data in all user tables. You must use a custom role or apply an explicit deny rule for delete.

What happens if I add the agent to db_denydatawriter?

The db_denydatawriter role blocks the user from adding, changing, or deleting any table data. This is great for read-only tasks, but it stops the agent from inserting new records.

Should I use a standard login or a contained user for Devin?

Use a contained database user if the agent only needs one or a few databases. This avoids creating a login in master, though an admin must enable contained databases first.

The query runs. The emails stay hidden.