Databases
Let the database reject bad data
Duplicates, empty fields and orphaned rows creep in because only the form checks them.
- What you get
- Constraints for the rules that matter, and a clean-up plan for rows that already break them.
- Paste it into
- Your AI tool, in your project
The prompt
My app only validates data in the form, so bad rows still get into the database. Read the schema and the code and list the rules the data is supposed to follow: required fields, unique values such as email, allowed status values, amounts that can't be negative, rows that must belong to an existing parent. Mark which ones the database enforces today. For each missing rule, first count the existing rows that break it and show me examples. Propose how to clean those up, then add the constraint in a migration. Make sure the app shows a friendly message when the database says no, instead of a raw error.
Use it
Open your AI tool (Claude Code, Codex or Cursor) in your project folder and paste it in.
More in Databases
Delete a user and everything they own
Someone asks you to delete their account, and their data is scattered across tables and services.
Fill your local app with realistic test data
Your local database is empty, so you test against production or three rows named “test”.
Design your tables before you build
The AI invents a new table every time you add a feature, and nothing lines up.
Check that users can’t read each other’s data
Every signed-in user may be able to fetch every row, and the app only hides it in the interface.