Laravel Patches v4.0.0
We are excited to announce the release of Laravel Patches v4.0, featuring a completely rewritten test suite using Pest, enhanced CLI tools for better visibility, and robust safeguards for your patch workflow. This release focuses on developer experience and reliability, ensuring you can manage your database patches with the same confidence as your migrations.
Laravel Patches v4 - Stability, Transparency, and Control
🚀 Key Features
1. Robust Status Command
The patch:status command has been overhauled to give you a clear, migration-style overview of your patches.
- Detailed Table View: See exactly which patches ran, when, and their status at a glance.
- Filtering: Quickly find what you need with
--pending,--ran, or--batch=<number>filters. - Execution Metrics: Now tracks and displays execution time (ms) directly in the status output.
2. Dry Run Mode
Preview your operation before committing to it.
- Run
php artisan patch --dry-runto see exactly which patches would execute without actually running them or modifying your database. - Perfect for double-checking the order of operations in production environments.
3. Atomic Transactions
Ensure your data integrity with built-in transaction support.
- Configurable Safety: Patches now respect a global
use_transactionsconfig setting. - Granular Control: Override the global setting on a per-patch basis with the
public bool $useTransactionproperty. - If a patch fails within a transaction, all database changes are automatically rolled back.
4. Detailed Metadata Tracking
Know exactly who, where, and how a patch was run. The patches table now automatically captures:
- Execution Time: Performance tracking in milliseconds.
- Memory Usage: Peak memory usage during the patch execution.
- Authenticated User: Records the console user (or authenticated app user) who triggered the patch.
- Environment: Logs the environment (local, production, staging) where the patch was executed.
5. Enhanced Error Handling
Failures are now first-class citizens.
- Stop on Error: Configurable option to halt execution immediately if a patch fails, preventing cascading issues.
- Failure Logging: Full exception messages and stack traces are logged directly to the database for failed patches, making debugging effortless.
6. Event System
Hook into the patch lifecycle with a new suite of events:
PatchExecuting/PatchExecutedPatchFailedPatchRollingBack/PatchRolledBack
Upgrading
To upgrade, update your composer.json dependency:
1"require": {2 "rappasoft/laravel-patches": "^4.0"3}
Then run composer update.
Testing
We have migrated our entire test suite to PestPHP, ensuring a modern, maintainable, and reliable foundation for future development. Run the suite locally with:
1composer test