PHPackages                             sufyandev/laravel-migration-linter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. sufyandev/laravel-migration-linter

ActiveLibrary[Database &amp; ORM](/categories/database)

sufyandev/laravel-migration-linter
==================================

A lightweight Laravel package that analyzes and warns about risky database migration changes before they reach production.

v2.1.2(3mo ago)68941MITPHPPHP ^8.1|^8.2|^8.3CI passing

Since Oct 16Pushed 3mo agoCompare

[ Source](https://github.com/muhammad-sufyan5/sufyan-laravel-migration-lint-package)[ Packagist](https://packagist.org/packages/sufyandev/laravel-migration-linter)[ Docs](https://muhammad-sufyan5.github.io/sufyan-laravel-migration-lint-package/)[ RSS](/packages/sufyandev-laravel-migration-linter/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (6)Versions (17)Used By (0)

🧩 Laravel Migration Linter
==========================

[](#-laravel-migration-linter)

 [![Laravel Migration Linter report](assets/preview.png)](assets/preview.png)

[![Docs](https://camo.githubusercontent.com/bd9b51e458cf856a4d1006283e1e7e8c1e2809eb8dc0526dbbdad547af0dad8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d6f6e6c696e652d627269676874677265656e3f7374796c653d666c61742d737175617265)](https://muhammad-sufyan5.github.io/sufyan-laravel-migration-lint-package/)[![Migration Linter](https://github.com/muhammad-sufyan5/sufyan-laravel-migration-lint-package/actions/workflows/migration-linter.yml/badge.svg)](https://github.com/muhammad-sufyan5/sufyan-laravel-migration-lint-package/actions)[![Latest Version on Packagist](https://camo.githubusercontent.com/203f7866aaf598ec8dbf46e49e7a24258be4a01f4a438cdfa2bc3b04a65a220b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73756679616e6465762f6c61726176656c2d6d6967726174696f6e2d6c696e7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sufyandev/laravel-migration-linter)[![Total Downloads](https://camo.githubusercontent.com/ce75fa807a02a089e53f71077d45f80b68d46ffe1ea5fad635af94fdf63ae873/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73756679616e6465762f6c61726176656c2d6d6967726174696f6e2d6c696e7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sufyandev/laravel-migration-linter)[![Laravel Version](https://camo.githubusercontent.com/ba8b0c98135fe2f82ded9e3031a388946b586cfc01918158a8b014eacfdba0a1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302532422d6f72616e67653f7374796c653d666c61742d737175617265)](#)[![PHP Version](https://camo.githubusercontent.com/fca6a5abe8cb8ca5a09d7514f79421a5acfc883e66c5e71627c5051291b2c4ce/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c75653f7374796c653d666c61742d737175617265)](#)[![Version](https://camo.githubusercontent.com/a5a9492a4d90a298bce3c200c8c1f31abae05dd248a0b6984271aefad75647ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d76322e312e312d677265656e3f7374796c653d666c61742d737175617265)](#)[![License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A lightweight Laravel package that **analyzes your database migrations** and warns you about risky schema changes — before they reach production.

---

🚀 Features
----------

[](#-features)

- 🔍 Detects dangerous migration patterns:
    - Non-nullable columns without defaults
    - Missing indexes on foreign keys
    - Unsafe column drops
    - Risky unique constraints
    - Floating-point money fields
    - Unsafe column renaming (table locks)
    - Column type changes on large tables (table locks)
    - Soft deletes on large tables
- ⚙️ Configurable rule severities (`info`, `warning`, `error`)
- 💡 **Actionable suggestions** — Each warning includes fix recommendations with grouped display
- 🔗 **Documentation links** — Every suggestion has a link to detailed docs
- 🧠 Baseline support to ignore legacy issues
- 🧾 JSON or table output for CI/CD (with suggestions included)
- 📊 **HTML Reports** — Generate beautiful, interactive HTML reports with charts and filtering
- 🎨 **Clean output** — Suggestions grouped by rule type to avoid repetition
- 🧩 Fully documented &amp; tested (84 tests, 200 assertions)

📘 **Read full rule docs:**
👉

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require sufyandev/laravel-migration-linter --dev
```

The package will auto-register via Laravel’s package discovery.

---

🧩 Usage
-------

[](#-usage)

Run the built-in Artisan command to lint all migration files:

```
php artisan migrate:lint
```

### Common Options

[](#common-options)

OptionDescription`--json`Output structured JSON (great for CI)`--html=`Generate interactive HTML report (default: storage/app/...)`--path=`Lint a specific migration file/folder`--baseline`Use a custom baseline file`--generate-baseline`Create a baseline to ignore current issues`--rules`View all rules and their enabled status`--summary`Display summary footer in output`--no-suggestions`Hide suggestions (show only warnings table)### Example Usage

[](#example-usage)

Lint all migrations and export JSON:

```
php artisan migrate:lint --json > storage/lint-report.json
```

Generate a new baseline file (ignore current issues):

```
php artisan migrate:lint --generate-baseline
```

Sample warning output:

```
[warning] AddUniqueConstraintOnNonEmptyColumn
→ Adding unique constraint to 'email' may fail if duplicates exist in 'users'.

```

---

📋 Scope &amp; Limitations
-------------------------

[](#-scope--limitations)

### What We Analyze

[](#what-we-analyze)

✅ **Laravel Schema Builder Operations** — All `$table->` method calls
✅ **Schema::create()** and **Schema::table()** methods
✅ **Column modifications** via `->change()`
✅ **Foreign keys**, **indexes**, **constraints**, **timestamps**

### What We Don't Analyze (By Design)

[](#what-we-dont-analyze-by-design)

⚠️ Raw SQL queries (`DB::statement()`, `DB::raw()`, etc.)
⚠️ Direct Eloquent operations (`User::update()`, model factories)
⚠️ Model traits and properties
⚠️ Data seeding operations

**Reason:** The linter focuses on statically analyzing schema builder patterns, which represent 99% of migration files. Raw SQL analysis requires different tooling.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#reason-the-linter-focuses-on-statically-analyzing-schema-builder-patterns-which-represent-99-of-migration-files-raw-sql-analysis-requires-different-tooling)

⚙️ Configuration
----------------

[](#️-configuration)

You can publish the configuration file to customize rule settings:

```
php artisan vendor:publish --tag="migration-linter-config"
```

The config file (`config/migration-linter.php`) allows you to:

- Set severity threshold (`info`, `warning`, `error`)
- Enable/disable specific rules
- Customize rule severity levels

Example configuration:

```
return [
    'severity_threshold' => 'warning',
    'rules' => [
        'AddNonNullableColumnWithoutDefault' => ['enabled' => true, 'severity' => 'warning'],
        'MissingIndexOnForeignKey'           => ['enabled' => true, 'severity' => 'warning'],
        // ... other rules
    ],
];
```

---

🧾 CI/CD Integration (GitHub Actions)
------------------------------------

[](#-cicd-integration-github-actions)

```
name: Laravel Migration Linter
on: [push, pull_request]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: shivammathur/setup-php@v2
        with:
          php-version: 8.3
      - run: composer install --no-interaction
      - run: php artisan migrate:lint --json > lint-report.json
```

---

✨ What's New in v2.0.0
----------------------

[](#-whats-new-in-v200)

**Complete SOLID Principles Refactoring**

- 🏗️ **8 Core Interfaces** — Dependency injection contracts for all components
- 🔧 **3 Service Classes** — Reusable business logic layer (LaravelConfigProvider, SeverityResolver, LintService)
- 🎨 **5 Formatter Classes** — Modular output system (Table, JSON, Compact, Summary, Base)
- 🔌 **Dependency Injection** — Automatic container bindings via service provider
- 📊 **Enhanced Architecture** — SOLID principles throughout (SRP, OCP, LSP, ISP, DIP)
- ✅ **144 tests passing** — Comprehensive test coverage with 259 assertions
- 🔄 **100% backward compatible** — No breaking changes, all v1.4.0 commands work identically
- 🎯 **Better table formatting** — Fixed Symfony Table component for proper alignment

**Migration from v1.4.0:**All commands work exactly the same. No changes needed:

```
php artisan migrate:lint                  # Still works
php artisan migrate:lint --json           # Still works
php artisan migrate:lint --generate-baseline  # Still works
```

---

✨ What Was New in v1.4.0
------------------------

[](#-what-was-new-in-v140)

- Suggestions System — Each warning includes actionable fix recommendations
- Documentation Links — Every issue links to detailed docs for the rule
- SoftDeletesOnProduction — New rule for detecting unsafe soft deletes on large tables
- Enhanced Reporter — JSON and table output include suggestions
- 100% test coverage with 43 passing tests

🧑‍💻 Contributing
----------------

[](#‍-contributing)

Contributions are welcome! If you have an idea for a useful rule or enhancement, feel free to open a PR or issue.

---

🧾 License
---------

[](#-license)

Released under the MIT License. © 2025 Sufyan. All rights reserved.

---

🧠 Author
--------

[](#-author)

Muhammad Sufyan 📧 🐙 GitHub: @muhammad-sufyan5

“Smart developers don’t debug production — they lint migrations.”

📘 **Full Documentation:**
👉

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance78

Regular maintenance activity

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Recently: every ~26 days

Total

11

Last Release

115d ago

Major Versions

v1.4.1 → 2.0.02025-11-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/3e9a7d88e1068712c4185980adba6177113d428f1e2acbbbc2301611860c59f6?d=identicon)[muhammad-sufyan5](/maintainers/muhammad-sufyan5)

---

Top Contributors

[![muhammad-sufyan5](https://avatars.githubusercontent.com/u/52907510?v=4)](https://github.com/muhammad-sufyan5 "muhammad-sufyan5 (105 commits)")[![sufyandev01](https://avatars.githubusercontent.com/u/242625697?v=4)](https://github.com/sufyandev01 "sufyandev01 (1 commits)")

---

Tags

ci-cddatabaselaravellintermigrationsschemalaravelschemadatabasemigrationslinterci

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sufyandev-laravel-migration-linter/health.svg)

```
[![Health](https://phpackages.com/badges/sufyandev-laravel-migration-linter/health.svg)](https://phpackages.com/packages/sufyandev-laravel-migration-linter)
```

###  Alternatives

[nunomaduro/laravel-optimize-database

Publishes migrations that make your database production ready.

26441.3k](/packages/nunomaduro-laravel-optimize-database)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3628.3k](/packages/orptech-laravel-migration-partition)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3420.8k](/packages/dragon-code-laravel-data-dumper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
