Skip to content

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