Leave Database Overview
Summary
LeaveDbContext is the runtime and design-time EF Core model for all 12 Leave-owned and operational persisted objects.
Audience
Backend developers, QA, architects, DevOps engineers, and support engineers.
Overview
The service registers the PostgreSQL provider and uses code-first migrations. Repositories expose tracked DbSets, while UnitOfWork delegates to a single SaveChanges call. Before the EF save, aggregate domain events are converted into outbox records, allowing aggregate state and newly created outbox messages to participate in the same database commit.
The model includes Leave requests, balances, configuration, calendars, an Employee projection, carry-forward and encashment Foundation records, audit/timeline history, and an outbox. No processed-event or inbox table exists in LeaveDbContext; Employee projection idempotency is stored on the profile itself.
| Area | Verified behavior | Source |
|---|---|---|
| Provider/model | PostgreSQL EF Core code-first | microservices/src/leave-service/Program.cs |
| Context | One LeaveDbContext with a Leave-owned default schema | microservices/src/leave-service/Infrastructure/LeaveDbContext.cs |
| Repository/UoW | Tracked repositories and SaveChanges boundary | microservices/src/leave-service/Infrastructure/Persistence.cs |
| Tenant model | Eleven global filters; privileged-or-current-tenant predicate | microservices/src/leave-service/Infrastructure/LeaveDbContext.cs |
| Migrations | Three source-controlled migrations and current snapshot | microservices/src/leave-service/Infrastructure/Migrations/LeaveDbContextModelSnapshot.cs |
| Foundation | Carry-forward and encashment are persisted but lack end-to-end orchestration | microservices/src/leave-service/Domain/Leave/LeaveExtras.cs |
Compatibility persistence remains separate from the extracted context. Exact deployed names and connection configuration are intentionally excluded.
Source References
- microservices/src/leave-service/Infrastructure/LeaveDbContext.cs
- microservices/src/leave-service/Infrastructure/Persistence.cs
- microservices/src/leave-service/Program.cs
- microservices/src/leave-service/Domain/Leave/LeaveExtras.cs
Related Articles
See Also
Keywords
- LeaveDbContext
- EF Core
- Persistence architecture
Revision Information
- Status: Draft
- Last reviewed: 2026-07-15
- Review cycle: Quarterly