avocet-shores/laravel-rewind
Full version control for Eloquent models: rewind, fast-forward, restore, diff, and query point-in-time state. Uses a hybrid engine (diffs + snapshots) with configurable intervals, thread-safe locking, batch revisions, queued writes, and pruning.
Strengths:
status, payment_status) with queryable history, ideal for workflow-heavy domains (e.g., orders, tickets).Fit for Laravel Ecosystem:
Weaknesses:
snapshot_interval) or large models could bloat database size.Prerequisites:
updated_at timestamps (required for version ordering).old_values/new_values as JSON).Migration Path:
Rewindable trait to models, run migrations (current_version column), and publish config.initVersion() calls or manual seeding of RewindVersion records.Compatibility:
Critical Risks:
old_values/new_values are serializable.RewindVersionLockTimeout events).--keep=30 --days=90).rewind_versions table size.Moderate Risks:
$rewindStateFields) may misclassify changes if business logic evolves. Validate with:
snapshot_interval could degrade performance. Benchmark with:
Low Risks:
Use Case Alignment:
Performance Trade-offs:
snapshot_interval accordingly.)Operational Impact:
rewind_versions growth, lock timeouts.)Data Integrity:
RewindVersion data is corrupted? (Backups, manual repairs.)Testing Strategy:
Laravel Core:
Rewindable trait (no ORM changes).model.saved, model.deleted, etc., for versioning.listener_should_queue).Schedule::command().Database:
current_version (integer) and rewind_versions table (JSON fields for old_values/new_values).model_type, model_id, version, and created_at.Testing:
Rewind facade or use RewindTestCase helpers.DevOps:
php artisan rewind:add-version in migration pipelines.rewind_versions table growth, lock timeouts, and queue job failures.Assessment Phase:
Post, Order, User).Order::status).Pilot Phase:
Post).listener_should_queue = true) to avoid blocking writes.snapshot_interval (e.g., 5) and monitor storage growth.Rollout Phase:
Rewindable trait + current_version column to pilot models.Order).Optimization Phase:
snapshot_interval based on reconstruction benchmarks.--keep, --days) based on retention needs.| Component | Compatibility Notes |
|---|---|
| Laravel | Tested on Laravel 10+. May require minor adjustments for older versions. |
| PHP | Requires PHP 8.1+. Uses attributes (PHP 8.0+) and named arguments. |
| Databases | MySQL, PostgreSQL, SQLite (no vendor-specific queries). |
| Caching | Redis/Memcached recommended for production (file cache may bottleneck). |
| Queues | Supports database, Redis, etc. (Laravel’s queue system). |
| Testing | Works with Pest/PHPUnit. Facade mocking supported. |
| Existing Code | Non-versioned models unaffected. Opt-in via trait. |
How can I help you explore Laravel packages today?