This commit completes Day 15's primary objectives:
1. Database Migration - Add TenantId columns to Epic, Story, and WorkTask entities
2. TenantContext Service - Implement tenant context retrieval from JWT claims
Changes:
- Added TenantId property to Epic, Story, and WorkTask domain entities
- Updated entity factory methods to require TenantId parameter
- Modified Project.CreateEpic to pass TenantId from parent aggregate
- Modified Epic.CreateStory and Story.CreateTask to propagate TenantId
- Added EF Core configurations for TenantId mapping with proper indexes
- Created EF Core migration: AddTenantIdToEpicStoryTask
* Adds tenant_id columns to Epics, Stories, and Tasks tables
* Creates indexes: ix_epics_tenant_id, ix_stories_tenant_id, ix_tasks_tenant_id
* Uses default Guid.Empty for existing data (backward compatible)
- Implemented ITenantContext interface in Application layer
- Implemented TenantContext service in Infrastructure layer
* Retrieves tenant ID from JWT claims (tenant_id or tenantId)
* Throws UnauthorizedAccessException if tenant context unavailable
- Registered TenantContext as scoped service in DI container
- Added Global Query Filters for Epic, Story, and WorkTask entities
* Ensures automatic tenant isolation at database query level
* Prevents cross-tenant data access
Architecture:
- Follows the same pattern as Issue Management Module (Day 14)
- Maintains consistency with Project entity multi-tenancy implementation
- Ensures data isolation through both domain logic and database filters
Note: Unit tests require updates to pass TenantId parameter - will be addressed in follow-up commits
Reference: Day 15 roadmap (DAY15-22-PROJECTMANAGEMENT-ROADMAP.md)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>