ecto-constraint-debug

Solid

Debug Ecto constraint violations - trace triggers, check migrations, find duplicate data. Use when seeing unique_constraint, foreign_key_constraint, or check_constraint errors.

AI & Automation 437 stars 25 forks Updated today MIT

Install

View on GitHub

Quality Score: 94/100

Stars 20%
88
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Ecto Constraint Debugging > **Ash projects**: Ash surfaces DB constraints through its own error DSL. Use the `ash-framework` skill — `mix usage_rules.search_docs "constraint" -p ash_postgres`. Systematic approach to diagnosing constraint violations. Load when you see `Ecto.ConstraintError`, `unique_constraint`, `foreign_key_constraint`, or constraint-related changeset errors. ## Iron Laws 1. **READ THE CONSTRAINT NAME** — The constraint name (e.g., `links_url_index`) tells you exactly which index/constraint failed. Parse it from the error message first 2. **CHECK MIGRATION BEFORE CODE** — Verify the constraint definition in `priv/repo/migrations/` matches what the schema expects 3. **TRACE ALL INSERT PATHS** — Find every code path that inserts into the constrained table. The bug is often in a path you didn't consider 4. **RACE CONDITION UNTIL PROVEN OTHERWISE** — If validation passes but constraint fails, assume concurrent inserts until you prove a single-request cause ## Step-by-Step Debugging ### Step 1: Parse the Error Extract from the error message: - **Constraint name** (e.g., `users_email_index`) - **Table name** (e.g., `users`) - **Operation** (insert, update, or delete) - **Conflicting values** (if available in logs) ### Step 2: Find the Migration Use Grep to search for the constraint name in `priv/repo/migrations/`. Also check for `create unique_index`, `create index`, `add constraint`. Verify: Does the migration constraint match the schema's `unique_con...

Details

Author
oliver-kriska
Repository
oliver-kriska/claude-elixir-phoenix
Created
4 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

Data & Documents Listed

ecto

Use this skill working with Ecto queries. You should prefer Ash queries directly, but if that does not work for whatever reason, you can reach for Ecto.

0 Updated 2 months ago
mylanconnolly
AI & Automation Listed

constraint-solver

Constraint-based problem solving skill. Finds elegant solutions when the design space is heavily restricted — budget caps, time limits, technology mandates, team size, ethical bounds, regulatory requirements. Treats constraints as the design material, not the obstacle. Surfaces constraint violations early, ranks constraints by hardness, and finds solutions that satisfy all hard constraints while optimizing within soft ones. The tighter the constraints, the sharper the solution. Use when user says: very limited budget, we can't use X, strict deadline, only N people, regulatory constraint, tech stack is fixed, solve with these restrictions, must work within these limits, strong constraints, can't change the requirements, work within the box, solve this but we can only, tiny budget, no budget, works with these limitations, solve under constraint. Do NOT activate for: open-ended problems with no constraints, problems where the first step is to challenge the constraints themselves (use pre-mortem instead). First r

2 Updated 2 weeks ago
Sandeeprdy1729
AI & Automation Listed

constraint-design

This skill should be used when the user asks to "add a constraint", "design a constraint", "write a harness rule", "choose enforcement type", "promote a constraint", "configure a verification slot", or needs guidance on the Constraints section of HARNESS.md.

34 Updated today
Habitat-Thinking