ecto-constraint-debug

Analyze Ecto migration files and schema definitions to diagnose constraint violations.

517|35|Updated Feb 12, 2026
One-click install
npx skills add https://github.com/oliver-kriska/claude-elixir-phoenix --skill ecto-constraint-debug
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ecto-constraint-debug
Source: https://github.com/oliver-kriska/claude-elixir-phoenix/tree/main/plugins/elixir-phoenix/skills/ecto-constraint-debug
Command: npx skills add https://github.com/oliver-kriska/claude-elixir-phoenix --skill ecto-constraint-debug

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers systematically diagnose and resolve Ecto.ConstraintError issues, such as unique constraint violations, foreign key problems, and check constraint failures, which often halt development.

Core Features & Use Cases

  • Constraint Analysis: Parses error messages to identify the specific constraint and table involved.
  • Migration & Schema Verification: Checks migration files and schema definitions for discrepancies.
  • Code Path Tracing: Helps locate all code paths that interact with the constrained table.
  • Root Cause Identification: Provides patterns for common causes like race conditions, cast_assoc issues, and data inconsistencies.
  • Use Case: When an Ecto.ConstraintError occurs during a user registration process due to a duplicate email, this Skill guides you to check the unique_constraint in the migration, find the relevant schema, trace the insert paths, and apply an upsert pattern to fix it.

Quick Start

Use the ecto-constraint-debug skill to debug a unique_constraint error on the users table.

Frequently Asked Questions about ecto-constraint-debug

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug an Ecto ConstraintError in my Phoenix application?

To debug an Ecto ConstraintError, you need to analyze your migration files and schema definitions to find discrepancies. This process traces insert and update code paths to identify the root cause of unique, foreign key, or check constraint violations.

What causes unique constraint violations during concurrent Ecto database insertions?

Unique constraint violations during concurrent Ecto insertions are typically caused by race conditions. Identifying these root causes involves checking transaction isolation and applying patterns like upserts to handle data deduplication and resolve the concurrent conflicts.

How do I trace foreign_key_constraint errors in an Elixir application?

Tracing foreign_key_constraint errors requires checking your migration files and schema definitions for inconsistencies. You must locate all code paths interacting with the constrained table to identify data inconsistencies or missing associations causing the failure.

Why does my Ecto check_constraint fail when updating a record?

An Ecto check_constraint fails when the data being written violates database-level rules. Debugging this involves parsing the error message, verifying the schema definition, and tracing the update code path to find the exact data causing the violation.

What is the best way to resolve race conditions causing Ecto constraint errors?

The best way to resolve race conditions causing Ecto constraint errors is to apply an upsert pattern. This approach handles data deduplication and transaction isolation correctly, preventing concurrent insertions from triggering unique constraint violations.

Do I need specific migration files to debug Ecto constraint violations?

Yes, you need specific migration files to debug Ecto constraint violations effectively. Analyzing these files alongside schema definitions allows you to identify discrepancies between the database structure and your application code causing the errors.