Skip to main content

Attendance Database Schema Reference

Summary​

The current Attendance EF model contains 13 persisted objects, 18 indexes, six unique indexes, one modeled foreign key, and global tenant filters on 12 objects.

Audience​

  • Backend developers, QA engineers, database reviewers, architects, and schema-automation authors

Reference Content​

Source-reference keys​

KeyRepository-relative source
S1microservices/src/attendance-service/Infrastructure/AttendanceDbContext.cs
S2microservices/src/attendance-service/Infrastructure/Migrations/AttendanceDbContextModelSnapshot.cs
S3microservices/src/attendance-service/Infrastructure/Persistence.cs
S4microservices/src/attendance-service/Backfill/ShiftPolicyBackfillTypes.cs

DbContexts​

ContextClassificationResponsibilitySource
AttendanceDbContextRuntime/design modelAll 13 Attendance-owned and operational objectsS1
ShiftPolicyBackfillDbContextTransitional specialized targetSame model, but preserves legacy Shift compatibility identityS4

The design-time factory creates AttendanceDbContext; it is not another persisted model.

Persisted objects​

GroupObjectPurpose / classificationTenant scopeIDRelationshipsUniqueness / indexesSource
Attendance coreAttendanceRecordsDaily employee outcome / masterFilteredIntegerLogical punch/reopen linksemployee/date and approval lookup, non-uniqueS1
Punch/reopeningAttendancePunchesCaptured punch aggregate / masterFilteredIntegerLogical employee/dateemployee/time indexS1
Punch/reopeningAttendanceReopenRequestsCorrection workflow / masterFilteredIntegerOptional logical AttendanceIdemployee/date/status indexS1
Time OfficeShiftsWork window / master, TransitionalFilteredInteger + compatibility integerLogical assignmentsunique compatibility; tenant/activeS1
Time OfficeWeeklyOffRulesTenant off-day / masterFilteredIntegerNoneunique tenant/dayS1
Time OfficeAttendancePoliciesTenant calculation policy / FoundationFilteredIntegerOwns rulestenant/active; unique filtered defaultS1
Time OfficeAttendancePolicyRulesPolicy child / FoundationFilteredIntegerRequired policy FK, cascadeunique policy/keyS1
Time OfficeEmployeeShiftAssignmentsEffective roster / master, TransitionalFilteredIntegerLogical Shift and employee refsemployee/from; Shift lookupS1
Employee profileEmployeeProfilesAttendance-local read modelFilteredExternal integerExternal employee reftenant/activeS1
Payroll snapshotsPayrollApprovedSnapshotsPeriod snapshot / read modelFilteredIntegerExternal employee/period refsunique employee/periodS1
Audit/timelineAttendanceAuditLogsTechnical audit / historyFilteredGUIDLogical entity reftenant/timeS1
Audit/timelineAttendanceTimelineBusiness activity / historyFilteredGUIDLogical entity reftenant/timeS1
MessagingOutboxMessagesIntegration delivery state / operationalNo global filterGUIDEvent context onlyunique event; status/timeS1

Relationship and constraint inventory​

Relationship or ruleDatabase enforcementSource
Policy to rulesRequired FK with cascade deleteS1, S2
Assignment to ShiftNo FK; application lookupS1, S3
Reopen to AttendanceNullable identifier; no FKS1, S2
Punch to AttendanceEmployee/date convention; no FKS1, S2
Employee referencesExternal numeric identifiers; no FKS1, S2
Daily Attendance uniquenessNo unique constraintS1, S2
Pending reopen / assignment overlapApplication checks onlyS3

Migration inventory​

MigrationObjects/changeSource
Initial Attendance schemaSeven initial objects and nine indexesmicroservices/src/attendance-service/Infrastructure/Migrations/20260702135737_InitialAttendanceSchema.cs
Time Office foundationSix objects, one FK, and nine indexesmicroservices/src/attendance-service/Infrastructure/Migrations/20260709123504_AddShiftWeeklyOffPolicyFoundation.cs
Assignment compatibility userOne nullable columnmicroservices/src/attendance-service/Infrastructure/Migrations/20260709143830_AddEmployeeShiftAssignmentUserId.cs

Query filters and transaction participants​

ParticipantBehaviorSource
12 business/history objectsprivileged-or-current-tenant global filterS1
Outboxunfiltered operational pollingS1, S3
Aggregate statetracked by repositories and committed by unit of workS3
Audit/timelineparticipates when added before the saveS3
Domain-event outboxadded before base saveS1
Payroll lock serviceexternal; outside database transactionS3

Compatibility components​

ComponentRoleSource
Specialized target contextPreserve Shift compatibility identityS4
Monolith source readerRead-only source accessmicroservices/src/attendance-service/Backfill/AttendanceMonolithSourceReader.cs
Runner and validatorsBatch, resume, dry-run, and paritymicroservices/src/attendance-service/Backfill/ShiftWeeklyOffBackfillRunner.cs

Source References​

  • microservices/src/attendance-service/Infrastructure/AttendanceDbContext.cs
  • microservices/src/attendance-service/Infrastructure/Migrations/AttendanceDbContextModelSnapshot.cs
  • microservices/src/attendance-service/Backfill/ShiftPolicyBackfillTypes.cs
  • microservices/src/attendance-service/Infrastructure/Persistence.cs

See Also​

Keywords​

  • Attendance persistence
  • EF Core
  • PostgreSQL

Revision Information​

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