Yaojia Wang 12a4248430 feat(backend): Day 15 Task 1&2 - Add TenantId to Epic/Story/WorkTask and implement TenantContext
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>
2025-11-04 16:44:09 +01:00
2025-11-04 12:28:53 +01:00
2025-11-02 23:55:18 +01:00
2025-11-03 11:51:02 +01:00
2025-11-03 20:02:41 +01:00
2025-11-02 23:55:18 +01:00
2025-11-02 23:55:18 +01:00
2025-11-02 23:55:18 +01:00
2025-11-02 23:55:18 +01:00
2025-11-02 23:55:18 +01:00
2025-11-03 11:51:02 +01:00
2025-11-02 23:55:18 +01:00
2025-11-02 23:55:18 +01:00
2025-11-02 23:55:18 +01:00
2025-11-02 23:55:18 +01:00
2025-11-04 12:28:53 +01:00
2025-11-04 12:28:53 +01:00
2025-11-02 23:55:18 +01:00
2025-11-02 23:55:18 +01:00
Description
No description provided
3.4 MiB
Languages
C# 88.5%
PowerShell 10.4%
Shell 0.8%
Dockerfile 0.3%