Releases: aliziodev/laravel-taxonomy
Releases · aliziodev/laravel-taxonomy
v2.4.3
v2.4.2
v2.4.1
v2.4.0
v2.3.0
2.3.0 (2025-07-03)
⚠ BREAKING CHANGES
- Composite Unique Slugs: Implementation of composite unique slug system for taxonomies that changes how slug uniqueness is handled. Previously slugs only needed to be globally unique, now uniqueness is determined by the combination of
slug,type, andparent_id. This change requires database migration and may affect code that relies on global slug uniqueness assumptions.
Features
- Composite Unique Slugs for Taxonomies (c7c6d58)
- Added composite unique constraint on
slug,type, andparent_idcolumns - Allows same slug for different taxonomy types or different parents
- Improves flexibility in taxonomy hierarchy management
- Provides automatic migration to update database structure
- Adds validation to prevent slug duplication within the same context
- Added composite unique constraint on
Migration Guide
To upgrade from v2.2.1 to v2.3.0:
- Backup Database: Ensure you backup your database before upgrading
- Update Package: Run
composer update aliziodev/laravel-taxonomy - Create Migration: Generate migration file for database schema changes
- Handle Conflicts: Check and resolve any existing slug conflicts across different types
- Run Migration: Execute the migration to update database constraints
- Review Code: Update any code that relies on global slug uniqueness
- Test Thoroughly: Perform comprehensive testing on taxonomy features
Technical Details
This change affects:
- Database Schema: Addition of composite unique constraint
- Model Validation: Updated validation rules for slugs
- Query Logic: Adjustments to queries that depend on slug uniqueness
- API Behavior: Changes in API behavior for handling duplicate slugs
For complete upgrade information, please refer to the UPGRADE.md file.
v2.2.1
v2.2.0
v2.1.0
v2.0.2
🚀 Major Features Added
Nested Set Model Implementation
- Added complete Nested Set Model support for hierarchical data management
- Implemented automatic left/right boundary calculation (
lft,rgt,depthfields) - Added efficient tree traversal methods for ancestors, descendants, and siblings
- Integrated automatic nested set maintenance on create, update, and delete operations
Performance Optimizations
- Added bulk operations support for large-scale taxonomy management
- Implemented efficient tree rebuilding with
rebuildNestedSet()method - Added performance monitoring and benchmarking capabilities
- Optimized database queries using nested set boundaries instead of recursive queries
Advanced Tree Operations
- Added
moveToParent()method for efficient node repositioning - Implemented cascade delete with orphan prevention
- Added tree validation and integrity checking
- Support for concurrent operations with race condition handling
Console Commands
- Added
taxonomy:rebuild-nested-setcommand for rebuilding nested set values - Enhanced
taxonomy:installcommand with better error handling
🔧 Technical Improvements
Database Schema Enhancements
-- Added nested set fields to taxonomies table
ALTER TABLE taxonomies ADD COLUMN lft INTEGER;
ALTER TABLE taxonomies ADD COLUMN rgt INTEGER;
ALTER TABLE taxonomies ADD COLUMN depth INTEGER DEFAULT 0;
-- Added indexes for performance
CREATE INDEX idx_taxonomies_nested_set ON taxonomies(type, lft, rgt);
CREATE INDEX idx_taxonomies_parent ON taxonomies(parent_id);Model Enhancements
- Enhanced Taxonomy model with nested set methods:
getAncestors()- Get all parent nodesgetDescendants()- Get all child nodesgetSiblings()- Get nodes at same levelgetNestedTree()- Get complete tree structureisAncestorOf()- Check parent-child relationshipisDescendantOf()- Check child-parent relationship
Service Layer Improvements
- Added TaxonomyManager service for complex operations
- Implemented transaction-safe operations for data integrity
- Added batch processing capabilities for large datasets
- Enhanced error handling with custom exceptions
🧪 Testing Infrastructure
Comprehensive Test Suite
- Added ExtremeTaxonomyTest for edge cases and large datasets
- Added TaxonomyPerformanceTest for performance benchmarking
- Added TaxonomyConcurrencyTest for race condition testing
- Added NestedSetTest for nested set specific operations
Performance Test Coverage
- Move operation efficiency testing with time assertions
- Descendants retrieval performance for various tree sizes
- Delete operations with cascade and orphan prevention
- Memory usage monitoring for large operations
- Concurrent operation handling with database transactions
📊 Performance Metrics
Before Nested Set (v1.x)
- Tree traversal: O(n) recursive queries
- Ancestor retrieval: Multiple database hits
- Move operations: Expensive parent_id updates
- Large trees: Performance degradation
After Nested Set (v2.0)
- Tree traversal: O(1) single query with boundaries
- Ancestor retrieval: Single query with lft/rgt comparison
- Move operations: Efficient boundary recalculation
- Large trees: Consistent performance up to 10,000+ nodes
🔄 Migration Guide
Database Migration
# Run the migration to add nested set fields
php artisan migrate
# Rebuild nested set values for existing data
php artisan taxonomy:rebuild-nested-set
# Rebuild specific taxonomy type
php artisan taxonomy:rebuild-nested-set category
# Force rebuild without confirmation
php artisan taxonomy:rebuild-nested-set --forceCode Updates
// Old way (v1.x)
$children = $taxonomy->children;
$ancestors = $this->getAncestorsRecursively($taxonomy);
// New way (v2.0)
$children = $taxonomy->getDescendants();
$ancestors = $taxonomy->getAncestors();⚠️ Breaking Changes
- Database schema changes require migration
- Some method signatures changed for consistency
- Performance test thresholds may need adjustment for different environments
- Soft delete behavior modified for nested set integrity
🐛 Bug Fixes
- Fixed race conditions in concurrent move operations
- Resolved orphan node issues in delete operations
- Fixed nested set boundary corruption in edge cases
- Corrected performance test assertions for realistic expectations
📚 Documentation
- Added comprehensive API documentation for all nested set methods
- Created performance benchmarking guide with optimization tips
- Added migration guide for upgrading from v1.x
- Enhanced README with nested set usage examples
v2.0.1
🚀 Major Features Added
Nested Set Model Implementation
- Added complete Nested Set Model support for hierarchical data management
- Implemented automatic left/right boundary calculation (
lft,rgt,depthfields) - Added efficient tree traversal methods for ancestors, descendants, and siblings
- Integrated automatic nested set maintenance on create, update, and delete operations
Performance Optimizations
- Added bulk operations support for large-scale taxonomy management
- Implemented efficient tree rebuilding with
rebuildNestedSet()method - Added performance monitoring and benchmarking capabilities
- Optimized database queries using nested set boundaries instead of recursive queries
Advanced Tree Operations
- Added
moveToParent()method for efficient node repositioning - Implemented cascade delete with orphan prevention
- Added tree validation and integrity checking
- Support for concurrent operations with race condition handling
Console Commands
- Added
taxonomy:rebuild-nested-setcommand for rebuilding nested set values - Enhanced
taxonomy:installcommand with better error handling
🔧 Technical Improvements
Database Schema Enhancements
-- Added nested set fields to taxonomies table
ALTER TABLE taxonomies ADD COLUMN lft INTEGER;
ALTER TABLE taxonomies ADD COLUMN rgt INTEGER;
ALTER TABLE taxonomies ADD COLUMN depth INTEGER DEFAULT 0;
-- Added indexes for performance
CREATE INDEX idx_taxonomies_nested_set ON taxonomies(type, lft, rgt);
CREATE INDEX idx_taxonomies_parent ON taxonomies(parent_id);Model Enhancements
- Enhanced Taxonomy model with nested set methods:
getAncestors()- Get all parent nodesgetDescendants()- Get all child nodesgetSiblings()- Get nodes at same levelgetNestedTree()- Get complete tree structureisAncestorOf()- Check parent-child relationshipisDescendantOf()- Check child-parent relationship
Service Layer Improvements
- Added TaxonomyManager service for complex operations
- Implemented transaction-safe operations for data integrity
- Added batch processing capabilities for large datasets
- Enhanced error handling with custom exceptions
🧪 Testing Infrastructure
Comprehensive Test Suite
- Added ExtremeTaxonomyTest for edge cases and large datasets
- Added TaxonomyPerformanceTest for performance benchmarking
- Added TaxonomyConcurrencyTest for race condition testing
- Added NestedSetTest for nested set specific operations
Performance Test Coverage
- Move operation efficiency testing with time assertions
- Descendants retrieval performance for various tree sizes
- Delete operations with cascade and orphan prevention
- Memory usage monitoring for large operations
- Concurrent operation handling with database transactions
📊 Performance Metrics
Before Nested Set (v1.x)
- Tree traversal: O(n) recursive queries
- Ancestor retrieval: Multiple database hits
- Move operations: Expensive parent_id updates
- Large trees: Performance degradation
After Nested Set (v2.0)
- Tree traversal: O(1) single query with boundaries
- Ancestor retrieval: Single query with lft/rgt comparison
- Move operations: Efficient boundary recalculation
- Large trees: Consistent performance up to 10,000+ nodes
🔄 Migration Guide
Database Migration
# Run the migration to add nested set fields
php artisan migrate
# Rebuild nested set values for existing data
php artisan taxonomy:rebuild-nested-set
# Rebuild specific taxonomy type
php artisan taxonomy:rebuild-nested-set category
# Force rebuild without confirmation
php artisan taxonomy:rebuild-nested-set --forceCode Updates
// Old way (v1.x)
$children = $taxonomy->children;
$ancestors = $this->getAncestorsRecursively($taxonomy);
// New way (v2.0)
$children = $taxonomy->getDescendants();
$ancestors = $taxonomy->getAncestors();⚠️ Breaking Changes
- Database schema changes require migration
- Some method signatures changed for consistency
- Performance test thresholds may need adjustment for different environments
- Soft delete behavior modified for nested set integrity
🐛 Bug Fixes
- Fixed race conditions in concurrent move operations
- Resolved orphan node issues in delete operations
- Fixed nested set boundary corruption in edge cases
- Corrected performance test assertions for realistic expectations
📚 Documentation
- Added comprehensive API documentation for all nested set methods
- Created performance benchmarking guide with optimization tips
- Added migration guide for upgrading from v1.x
- Enhanced README with nested set usage examples