jamil / laravel-migration-guard
Detect dangerous Laravel migrations before running them in production
Package info
github.com/chowdhury-jamil-jc-787/laravel-migration-guard
pkg:composer/jamil/laravel-migration-guard
Requires
- php: ^8.1 || ^8.2 || ^8.3
- illuminate/support: ^10.0 || ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- orchestra/testbench: ^8.0 || ^9.0 || ^10.0 || ^11.0
- phpunit/phpunit: ^10.0 || ^11.0
This package is auto-updated.
Last update: 2026-04-13 06:03:26 UTC
README
Prevent dangerous database migrations before they break production.
Detect risky migrations like dropping tables, NOT NULL changes, raw SQL, and more — before deployment.
🚀 Quick Start
composer require jamil/laravel-migration-guard php artisan migrate:check
📸 Demo
⚠️ Why This Exists
Laravel migrations are powerful — but they can also break production:
- Table locks on large datasets
- Downtime during deployments
- Data loss from destructive operations
- Failed deployments due to unsafe schema changes
Laravel does not provide built-in safety checks.
This package helps you catch dangerous migrations before running them.
✨ Features
-
Scan pending migrations
-
Detect risky schema changes
-
Severity levels:
- HIGH
- MEDIUM
- LOW (coming soon)
-
Clear explanations of risks
-
Suggested safer approaches
-
CI support (
--ci) -
JSON output (
--json)
⚠️ What It Detects
🔴 High Risk
- Dropping tables (data loss)
- Dropping columns (data loss)
- Changing column types (table lock risk)
- Raw SQL usage (manual review required)
🟡 Medium Risk
- Adding indexes (performance impact)
- Adding unique indexes (duplicate data risk)
🧠 Smart Detection
- NOT NULL columns without
nullable()
📦 Installation
composer require jamil/laravel-migration-guard
🚀 Usage
php artisan migrate:check
⚠️ Example Output
Migration: 2026_04_10_drop_phone_from_users_table
[HIGH] Dropping column 'phone' may cause permanent data loss.
Summary:
High Risk: 1
🤖 CI Usage
php artisan migrate:check --ci
- Exit code
1if dangerous migrations detected - Perfect for CI/CD pipelines
📊 JSON Output
php artisan migrate:check --json
⚠️ Limitations
- Does not guarantee zero downtime
- Raw SQL requires manual review
- Some risks depend on table size and data volume
🛣 Roadmap
- More migration rules
- PostgreSQL support
- Django version
- GitHub Action
- Configurable rules
🤝 Contributing
PRs and ideas are welcome.
📄 License
MIT

