lc:check-foreign-keys

Analyzes Laravel migrations and Eloquent models to detect foreign key discrepancies.

12|2|Updated Apr 8, 2026
One-click install
npx skills add https://github.com/edulazaro/laraclaude --skill lc-check-foreign-keys
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lc:check-foreign-keys
Source: https://github.com/edulazaro/laraclaude/tree/main/skills/check-foreign-keys
Command: npx skills add https://github.com/edulazaro/laraclaude --skill lc-check-foreign-keys

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill resolves inconsistencies between database-level foreign key constraints and application-level Eloquent model relationships, preventing runtime errors and data integrity issues.

Core Features & Use Cases

  • Automated Detection: Identifies orphaned relationships, missing foreign keys, and incorrect onDelete actions across your entire Laravel project.
  • Fix Generation: Automatically generates migration files and suggests model updates to align your database schema with your Eloquent definitions.
  • Use Case: Use this tool during a refactor to ensure that every belongsTo relationship in your models is backed by a corresponding foreign key constraint in your database migrations.

Quick Start

Run the check foreign keys skill to analyze your entire project for database inconsistencies and report all findings.

Frequently Asked Questions about lc:check-foreign-keys

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

FAQPage Schema
How do I check Laravel migrations for missing foreign key constraints?

To check Laravel migrations for missing foreign key constraints, you can analyze your codebase to cross-reference database migration definitions with Eloquent model relationship methods, detecting orphaned relationships and schema discrepancies.

Why does my Eloquent model relationship cause data integrity issues?

Eloquent model relationships cause data integrity issues when they lack corresponding database-level foreign key constraints, allowing orphaned records and runtime errors due to misaligned onDelete configurations and missing schema rules.

How do I find orphaned relationships and invalid onDelete configurations in Laravel?

You can find orphaned relationships and invalid onDelete configurations by scanning your entire Laravel project to cross-reference Eloquent relationship definitions against migration files, identifying missing constraints and incorrect cascade actions.

Can I automatically generate migration files to fix Eloquent relationship inconsistencies?

Yes, you can automatically generate migration files and suggest model updates to align your database schema with your Eloquent definitions, resolving missing foreign keys and invalid onDelete actions detected during the codebase analysis.

When should I validate database schema integrity during a Laravel refactor?

You should validate database schema integrity during a Laravel refactor to ensure every belongsTo relationship in your models is backed by a corresponding foreign key constraint, preventing runtime errors and maintaining data consistency.