Skip to main content

Leave Database Schema Reference

Summary

The current Leave EF model contains one DbContext, 12 persisted objects, 16 explicit indexes, four unique indexes, 12 primary keys, no foreign keys, and global tenant filters on 11 objects.

Audience

Backend developers, QA, database reviewers, architects, DevOps, and schema-automation authors.

Reference Content

Source-reference keys

KeyRepository-relative source
S1microservices/src/leave-service/Infrastructure/LeaveDbContext.cs
S2microservices/src/leave-service/Infrastructure/Migrations/LeaveDbContextModelSnapshot.cs
S3microservices/src/leave-service/Infrastructure/Persistence.cs
S4microservices/src/leave-service/Application/LeaveWorkflows.cs
S5microservices/src/leave-service/Messaging/EmployeeProfileConsumer.cs
S6Data/AppDbContext.cs

DbContexts

ContextClassificationResponsibilitySource
LeaveDbContextRuntime and design modelAll 12 Leave-owned and operational objectsS1

The design-time factory creates the same LeaveDbContext; it is not a second persisted model. The monolith AppDbContext is a separate Legacy / Transitional compatibility context, not part of the Leave-owned schema.

Persisted objects

GroupLogical objectPurpose / classificationTenant scopeIdentifierLogical relationshipsUniqueness/index summarySource
Leave coreLeaveRequestsRequest aggregate / masterFilteredInteger identityEmployee, timeline, balance, Workflow by identifiersThree non-unique indexesS1
Balance/policyLeaveBalancesAnnual employee/type balance / masterFilteredInteger identityEmployee/type by identifiersUnique tenant/user/type/yearS1
Balance/policyLeaveTypesType configuration / FoundationFilteredInteger identityType-name conventionUnique tenant/nameS1
Balance/policyLeavePoliciesPer-type policy / FoundationFilteredInteger identityType-name conventionUnique tenant/typeS1
CalendarHolidaysTenant calendar / master, TransitionalFilteredInteger identityCalculation inputTenant/date indexS1
CalendarWeeklyOffsRecurring tenant day / master, TransitionalFilteredInteger identityCalculation inputTenant/day indexS1
Employee projectionEmployeeProfilesLeave-local Employee read modelFilteredComposite tenant/laborExternal Employee identityTenant/user and tenant/external-ID indexesS1, S5
Carry/encashCarryForwardsYear-transfer record / FoundationFilteredInteger identityBalance by user/type/yearTenant/user/type/target-year indexS1
Carry/encashEncashmentsEncashment aggregate / FoundationFilteredInteger identityBalance by user/type/yearTenant/user/type/year indexS1
Audit/timelineAuditLogsTechnical audit / historyFilteredGUIDLogical entity referenceTenant/time indexS1
Audit/timelineLeaveTimelineBusiness history / historyFilteredInteger identityLogical request/employee referencesTenant/labor/time indexS1
Outbox/inboxOutboxMessagesIntegration delivery / operationalNo global filterGUIDEvent/correlation contextUnique event; status/time indexS1, S3

No Leave inbox/ProcessedIntegrationEvent object exists. Employee projection last-event fields are object-local idempotency metadata.

Relationship and foreign-key inventory

RelationshipDatabase FKActual enforcementSource
Request to EmployeeProfileNoLabor identifier convention and application lookupS3, S4
Request to TimelineNoOptional request identifier written by applicationS4
Request to WorkflowNoOptional external correlation identifierS1
Balance to EmployeeProfileNoUser identifier bridgeS3
Balance/type/policy/carry/encashNoLeave-type string and user/year conventionsS1, S3
Holiday/weekly off to requestsNoDate/day calculation queriesS4
Audit to entitiesNoString entity type/identifierS3

Foreign-key total: 0. Consequently no cascade, restrict, or set-null relationship is configured in LeaveDbContext.

Unique constraints and indexes

CategoryCountInventorySource
Primary keys12One per persisted object; EmployeeProfiles uses a composite keyS1, S2
Unique indexes4Balance scope; Leave type tenant/name; policy tenant/type; outbox event identityS1, S2
Non-unique indexes12Request (3), Holiday, weekly off, profile (2), carry forward, encashment, timeline, audit, outbox status/timeS1, S2
Explicit indexes total16Current snapshot totalS2

There are no check constraints, alternate keys, or concurrency-token mappings in the current model.

Query filters

ScopeCountPredicate modelSource
Business/projection/history/Foundation objects11Privileged context or current tenantS1
Operational outbox1 unfiltered objectCross-tenant Pending/Failed pollingS1, S3

Migration inventory

SequenceMigrationChangeSource
1InitialLeaveService12 objects and 14 indexesmicroservices/src/leave-service/Infrastructure/Migrations/20260702162726_InitialLeaveService.cs
2AddEmployeeProfileSyncFieldsProjection fields and one indexmicroservices/src/leave-service/Infrastructure/Migrations/20260703060858_AddEmployeeProfileSyncFields.cs
3AddLeaveWorkflowInstanceCorrelation field and one indexmicroservices/src/leave-service/Infrastructure/Migrations/20260706172733_AddLeaveWorkflowInstance.cs

Transaction participants

ParticipantBehaviorSource
Aggregate changesTracked and committed by unit of workS3
Audit/timelineSame commit when added before SaveChangesS3, S4
New outbox messagesAdded before base save and committed with that saveS1
Balance after decision/cancellationSeparate later saveS4
Attendance/Workflow callsOutside database transactionS4
Profile message acknowledgementAfter projection/audit saveS5

Compatibility objects

Object groupRoleSource
Legacy LeaveRequestMonolith compatibility request stateModels/LeaveRequest.cs
Legacy LeaveBalanceMonolith compatibility balance stateModels/LeaveBalance.cs
Legacy Holiday/WeeklyOffMonolith compatibility calendarModels/Holiday.cs; Models/WeeklyOff.cs
AppDbContextSeparate legacy ownership and tenant filtersS6

No source-confirmed backfill/synchronization object exists between these stores.

Source References

  • microservices/src/leave-service/Infrastructure/LeaveDbContext.cs
  • microservices/src/leave-service/Infrastructure/Migrations/LeaveDbContextModelSnapshot.cs
  • microservices/src/leave-service/Infrastructure/Persistence.cs
  • microservices/src/leave-service/Application/LeaveWorkflows.cs
  • microservices/src/leave-service/Messaging/EmployeeProfileConsumer.cs
  • Data/AppDbContext.cs

See Also

Keywords

  • Schema inventory
  • Database constraints
  • Persisted objects

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly