Skip to content

Hereby Database Schema — Reference

Generated from the live hereby_platform_local_1 database on 2026-05-20. Authoritative for the tables it lists — do not hand-edit (regenerate via the snippet at the bottom).

⚠️ This snapshot is stale (2026-05-20). The codebase now has 113 entity files (packages/database/src/entities/*.entity.ts) vs the 78 tables captured here. Whole domains added since are not in this snapshot: drive (drive_folders, drive_files, drive_access_grants, drive_share_links), AI (ai_conversations, ai_messages, doc_embeddings), e-sign (e_sign_records, sign_webhook_inbox), annual-leave-promotion (7 tables: batch/batch-item/event/plan-item/selection-snapshot/sign-attempt + root), account layer (accounts), offsite work (offsite_work_records, offsite_work_types), work-time-closing, and additional sheet/org-parameter tables. Regenerate before trusting the table list. Column definitions for the tables that ARE listed remain valid.

  • 78 tables (snapshot; current entity count is 113), 1134 columns, 161 foreign keys, 130 unique indexes.
  • All tables live in schema hereby. Every table extending BaseEntity carries id / createdAt / updatedAt / deletedAt (soft-delete) — these aren't called out per table to keep the doc scannable.
  • marks foreign keys. Unique constraints are listed under each table (partial indexes show their WHERE clause — important for soft-delete uniqueness).

Index

Identity & org

organizations

ColumnTypeNullDefault
namevarchar(255)NOT NULL
codevarchar(50)NULL
timezonevarchar(50)NOT NULL'Asia/Seoul'
localevarchar(10)NOT NULL'ko-KR'
currencyvarchar(3)NOT NULL'KRW'
fiscalYearStartintegerNOT NULL1
settingsjsonbNOT NULL'{}'
isActivebooleanNOT NULLtrue
subscriptionTiervarchar(50)NOT NULL'starter'
subscriptionExpiresAtdateNULL
billingInfojsonbNULL
legalNamevarchar(255)NULL
taxIdvarchar(50)NULL
typeUSER-DEFINEDNOT NULL'SME'
sizeUSER-DEFINEDNOT NULL'SMALL'
statusUSER-DEFINEDNOT NULL'TRIAL'
medicalFieldvarchar(100)NULL
websitevarchar()NULL
emailvarchar()NULL
phonevarchar()NULL
faxvarchar()NULL
addressjsonbNULL
billingAddressjsonbNULL
logovarchar()NULL
foundedDatedateNULL
fiscalYearEndvarchar()NULL
sealImagetextNULL
representativeNamevarchar(100)NULL
defaultShiftIduuidNULL

References: defaultShiftIdshifts

Unique:

  • id
  • code

employees

ColumnTypeNullDefault
employeeNumbervarchar()NOT NULL
firstNamevarchar()NOT NULL
lastNamevarchar()NOT NULL
middleNamevarchar()NULL
emailvarchar()NOT NULL
phonevarchar()NULL
passwordvarchar()NOT NULL
authMethodsARRAYNOT NULL'{email,phone_otp}'[]
biometricIdvarchar()NULL
statusUSER-DEFINEDNOT NULL'ACTIVE'
hireDatedateNOT NULL
profilePicturevarchar()NULL
addresstextNULL
emergencyContactjsonbNULL
bankAccounttextNULL
organizationIduuidNULL
lastLoginAttimestampNULL
passwordChangedAttimestampNULL
isSystemAdminbooleanNOT NULLfalse
shiftIduuidNULL
mustChangePasswordbooleanNOT NULLfalse
birthDatedateNULL
residentNumbertextNULL
attendanceMethodUSER-DEFINEDNULL

References: organizationIdorganizations, shiftIdshifts

Unique:

  • organizationId, employeeNumber WHERE (deletedAt IS NULL)
  • email
  • phone WHERE (phone IS NOT NULL)
  • phone
  • email
  • phone
  • id

employment_contracts

ColumnTypeNullDefault
contractNumbervarchar()NOT NULL
employeeIduuidNOT NULL
contractTypeUSER-DEFINEDNOT NULL
wageTypeUSER-DEFINEDNOT NULL
baseSalarynumeric(15,2)NOT NULL
hourlyRatenumeric(15,2)NULL
startDatedateNOT NULL
endDatedateNULL
standardWeeklyHoursintegerNOT NULL40
maxWeeklyHoursintegerNOT NULL52
allowancesjsonbNULL
deductionsjsonbNULL
benefitsjsonbNULL
isActivebooleanNOT NULLtrue
terminationReasonvarchar()NULL
metadatajsonbNULL
salaryGradeIduuidNULL
chainIduuidNOT NULL
versionintegerNOT NULL1
supersededAttimestampNULL
hobongAmountnumeric(15,2)NOT NULL0
longevityAmountnumeric(15,2)NOT NULL0

References: employeeIdemployees, salaryGradeIdsalary_grades

Unique:

  • chainId, version
  • id

employee_certifications

ColumnTypeNullDefault
employeeIduuidNOT NULL
typeUSER-DEFINEDNOT NULL
namevarchar()NOT NULL
licenseNumbertextNULL
issuingAuthorityvarchar()NULL
issueDatedateNULL
expiryDatedateNULL
isActivebooleanNOT NULLtrue
notesvarchar()NULL
organizationIduuidNOT NULL
storagePathvarchar()NULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • id

teams

ColumnTypeNullDefault
codevarchar()NULL
namevarchar()NOT NULL
descriptionvarchar()NULL
isActivebooleanNOT NULLtrue
leaderIduuidNULL
metadatajsonbNULL
organizationIduuidNOT NULL
parentTeamIduuidNULL

References: parentTeamIdteams, leaderIdemployees, organizationIdorganizations

Unique:

  • id

team_members

ColumnTypeNullDefault
teamIduuidNOT NULL
employeeIduuidNOT NULL
roleIduuidNULL
joinedAtdateNOT NULL
leftAtdateNULL
isActivebooleanNOT NULLtrue

References: roleIdroles, teamIdteams, employeeIdemployees

Unique:

  • id
  • teamId, employeeId

team_permissions

ColumnTypeNullDefault
teamIduuidNOT NULL
permissionIduuidNOT NULL
grantedAtdateNULL
expiresAtdateNULL
grantedByvarchar()NULL
isActivebooleanNOT NULLtrue
scopejsonbNULL

References: teamIdteams, permissionIdpermissions

Unique:

  • id
  • teamId, permissionId

roles

ColumnTypeNullDefault
codevarchar()NULL
namevarchar()NOT NULL
descriptionvarchar()NULL
typeUSER-DEFINEDNOT NULL'custom'
isActivebooleanNOT NULLtrue
metadatajsonbNULL
organizationIduuidNULL

References: organizationIdorganizations

Unique:

  • id

role_permissions

ColumnTypeNullDefault
roleIduuidNOT NULL
permissionIduuidNOT NULL

References: permissionIdpermissions, roleIdroles

Unique:

  • roleId, permissionId

permissions

ColumnTypeNullDefault
codevarchar()NOT NULL
namevarchar()NOT NULL
descriptionvarchar()NULL
resourcevarchar()NOT NULL
actionsARRAYNOT NULL
conditionsjsonbNULL
isActivebooleanNOT NULLtrue
parentIduuidNULL

References: parentIdpermissions

Unique:

  • code
  • id

permissions_closure

ColumnTypeNullDefault
id_ancestoruuidNOT NULL
id_descendantuuidNOT NULL

References: id_descendantpermissions, id_ancestorpermissions

Unique:

  • id_ancestor, id_descendant

auth_tokens

ColumnTypeNullDefault
tokenvarchar()NOT NULL
tokenTypeUSER-DEFINEDNOT NULL
statusUSER-DEFINEDNOT NULL'ACTIVE'
employeeIduuidNOT NULL
expiresAttimestampNOT NULL
lastUsedAttimestampNULL
ipAddressvarchar()NULL
userAgentvarchar()NULL
deviceIdvarchar()NULL
metadatajsonbNULL
organizationIdvarchar()NOT NULL

References: employeeIdemployees

Unique:

  • id
  • token
  • token

login_otp_codes

ColumnTypeNullDefault
phonevarchar()NOT NULL
codeHashvarchar()NOT NULL
employeeIduuidNOT NULL
organizationIduuidNOT NULL
expiresAttimestampNOT NULL
consumedAttimestampNULL
attemptsintegerNOT NULL0
ipAddressvarchar()NULL

References: employeeIdemployees

Unique:

  • id

device_tokens

ColumnTypeNullDefault
tokenvarchar()NOT NULL
platformUSER-DEFINEDNOT NULL
isActivebooleanNOT NULLtrue
lastUsedAttimestampNULL
employeeIduuidNOT NULL
organizationIduuidNOT NULL

References: employeeIdemployees, organizationIdorganizations

Unique:

  • token
  • id

Payroll & records

payroll_records

ColumnTypeNullDefault
payrollNumbervarchar()NOT NULL
employeeIduuidNOT NULL
yearintegerNOT NULL
monthintegerNOT NULL
periodStartdateNOT NULL
periodEnddateNOT NULL
totalDeductionsnumeric(15,2)NOT NULL'0'
netPaynumeric(15,2)NOT NULL'0'
statusUSER-DEFINEDNOT NULL'draft'
paymentDatedateNULL
paymentMethodvarchar()NULL
approvedByvarchar()NULL
approvedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL
paidAttimestampNULL
confirmedByvarchar()NULL
confirmedAttimestampNULL
grossPaynumeric(15,2)NOT NULL0
snapshotjsonbNULL
sentByvarchar()NULL
sentAttimestampNULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • payrollNumber
  • id

payroll_cell_memos

ColumnTypeNullDefault
organizationIduuidNOT NULL
employeeIduuidNULL
yearintegerNULL
monthintegerNULL
columnKeyvarchar(100)NOT NULL
memotextNOT NULL
statusUSER-DEFINEDNOT NULL'open'
createdByIduuidNOT NULL
resolvedByIduuidNULL
resolvedAttimestampNULL
sheetViewIduuidNULL
sheetRowIduuidNULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • id

allowance_records

ColumnTypeNullDefault
employeeIduuidNOT NULL
yearintegerNOT NULL
monthintegerNOT NULL
amountnumeric(15,2)NOT NULL
paymentMethodUSER-DEFINEDNOT NULL'salary'
reasonvarchar()NOT NULL
datedateNULL
statusUSER-DEFINEDNOT NULL'pending'
approvedByvarchar()NULL
approvedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL
payrollRecordIduuidNULL
isAutoGeneratedbooleanNOT NULLfalse
sourceTypeUSER-DEFINEDNULL
sourceIduuidNULL
inputSnapshotjsonbNULL
formulaVersionvarchar(32)NULL
sourceSheetIduuidNOT NULL
sourceSheetRowIduuidNOT NULL
sourceSheetColumnKeyvarchar(64)NOT NULL
appliedParametersjsonbNULL
allowanceItemCodeIduuidNULL

References: employeeIdemployees, organizationIdorganizations, allowanceItemCodeIdallowance_item_codes, sourceSheetRowIdsheet_rows, sourceSheetIdsheet_views, payrollRecordIdpayroll_records

Unique:

  • id
  • sourceSheetId, sourceSheetRowId, sourceSheetColumnKey WHERE (deletedAt IS NULL)

deduction_records

ColumnTypeNullDefault
employeeIduuidNOT NULL
yearintegerNOT NULL
monthintegerNOT NULL
amountnumeric(15,2)NOT NULL
reasonvarchar()NOT NULL
datedateNULL
statusUSER-DEFINEDNOT NULL'pending'
approvedByvarchar()NULL
approvedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL
payrollRecordIduuidNULL
isAutoGeneratedbooleanNOT NULLfalse
sourceTypeUSER-DEFINEDNULL
sourceIduuidNULL
inputSnapshotjsonbNULL
formulaVersionvarchar(32)NULL
sourceSheetIduuidNOT NULL
sourceSheetRowIduuidNOT NULL
sourceSheetColumnKeyvarchar(64)NOT NULL
appliedParametersjsonbNULL
deductionItemCodeIduuidNULL

References: organizationIdorganizations, employeeIdemployees, deductionItemCodeIddeduction_item_codes, sourceSheetIdsheet_views, payrollRecordIdpayroll_records, sourceSheetRowIdsheet_rows

Unique:

  • id
  • sourceSheetId, sourceSheetRowId, sourceSheetColumnKey WHERE (deletedAt IS NULL)

allowance_item_codes

ColumnTypeNullDefault
codevarchar(4)NOT NULL
namevarchar()NOT NULL
displayOrderintegerNOT NULL0
isActivebooleanNOT NULLtrue
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • organizationId, code
  • id

deduction_item_codes

ColumnTypeNullDefault
codevarchar(4)NOT NULL
namevarchar()NOT NULL
displayOrderintegerNOT NULL0
isActivebooleanNOT NULLtrue
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • organizationId, code
  • id

salary_grades

ColumnTypeNullDefault
gradeintegerNOT NULL
baseSalarynumeric(15,2)NOT NULL
hobongAmountnumeric(15,2)NOT NULL'0'
totalSalarynumeric(15,2)NOT NULL
annualSalarynumeric(15,2)NULL
effectiveYearintegerNOT NULL
minimumWagenumeric(15,2)NULL
monthlyHoursnumeric(7,2)NOT NULL'209'
statusUSER-DEFINEDNOT NULL'active'
notesvarchar()NULL
organizationIduuidNOT NULL
categoryIduuidNULL

References: organizationIdorganizations, categoryIdsalary_grade_categories

Unique:

  • organizationId, categoryId, grade, effectiveYear WHERE (deletedAt IS NULL)
  • id

salary_grade_categories

ColumnTypeNullDefault
namevarchar()NOT NULL
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id

tax_bracket_configs

ColumnTypeNullDefault
minIncomenumeric(15,2)NOT NULL
maxIncomenumeric(15,2)NOT NULL
ratenumeric(8,4)NOT NULL
deductionnumeric(15,2)NOT NULL0
effectiveYearintegerNOT NULL
isActivebooleanNOT NULLtrue
notesvarchar()NULL
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id

organization_parameters

ColumnTypeNullDefault
organizationIduuidNOT NULL
namespacevarchar(64)NOT NULL
keyvarchar(64)NOT NULL
typevarchar(16)NOT NULL
numberValuenumeric(,)NULL
stringValuetextNULL
booleanValuebooleanNULL
labelvarchar(200)NOT NULL
descriptiontextNULL
unitvarchar(16)NULL
updatedByuuidNULL

References: organizationIdorganizations

Unique:

  • id
  • organizationId, namespace, key WHERE (deletedAt IS NULL)

organization_parameter_history

ColumnTypeNullDefault
parameterIduuidNOT NULL
organizationIduuidNOT NULL
namespacevarchar(64)NOT NULL
keyvarchar(64)NOT NULL
typevarchar(16)NOT NULL
numberValuenumeric(,)NULL
stringValuetextNULL
booleanValuebooleanNULL
effectiveFromtimestampNOT NULLnow()
changedByuuidNULL
reasontextNULL

References: parameterIdorganization_parameters

Unique:

  • id

Attendance / shifts / leave

attendances

ColumnTypeNullDefault
employeeIduuidNOT NULL
datedateNOT NULL
shiftIduuidNULL
scheduledCheckIntimestampNULL
scheduledCheckOuttimestampNULL
actualCheckIntimestampNULL
actualCheckOuttimestampNULL
statusUSER-DEFINEDNOT NULL'scheduled'
typeUSER-DEFINEDNOT NULL'regular'
regularHoursnumeric(5,2)NOT NULL'0'
overtimeHoursnumeric(5,2)NOT NULL'0'
nightHoursnumeric(5,2)NOT NULL'0'
weekendHoursnumeric(5,2)NOT NULL'0'
holidayHoursnumeric(5,2)NOT NULL'0'
breakHoursnumeric(5,2)NOT NULL'0'
totalHoursnumeric(5,2)NOT NULL'0'
locationjsonbNULL
notesvarchar()NULL
approvedByvarchar()NULL
approvedAttimestampNULL
metadatajsonbNULL
organizationIduuidNULL

References: employeeIdemployees, shiftIdshifts, organizationIdorganizations

Unique:

  • employeeId, scheduledCheckIn WHERE ((scheduledCheckIn IS NOT NULL) AND (deletedAt IS NULL))
  • id

shifts

ColumnTypeNullDefault
codevarchar()NULL
namevarchar()NOT NULL
descriptionvarchar()NULL
typeUSER-DEFINEDNOT NULL
startTimetime without time zoneNOT NULL
endTimetime without time zoneNOT NULL
workHoursnumeric(5,2)NOT NULL
breakHoursnumeric(5,2)NOT NULL'1'
nightDifferentialRatenumeric(5,2)NULL
weekendDifferentialRatenumeric(5,2)NULL
holidayDifferentialRatenumeric(5,2)NULL
overtimeRatenumeric(5,2)NOT NULL1.5
isActivebooleanNOT NULLtrue
applicableDaysjsonbNULL
metadatajsonbNULL
organizationIduuidNULL

References: organizationIdorganizations

Unique:

  • id

overtime_records

ColumnTypeNullDefault
employeeIduuidNOT NULL
workDatedateNOT NULL
startTimetime without time zoneNULL
endTimetime without time zoneNULL
overtimeHoursnumeric(7,2)NOT NULL
mealBreakHoursnumeric(7,2)NOT NULL'0'
categoryUSER-DEFINEDNOT NULL'weekday'
statusUSER-DEFINEDNOT NULL'pending'
approvedByvarchar()NULL
approvedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL
chainIduuidNOT NULL
versionintegerNOT NULL1
supersededAttimestampNULL
rejectionReasontextNULL
reportjsonbNULL

References: employeeIdemployees, organizationIdorganizations

Unique:

  • id
  • chainId, version

leave_requests

ColumnTypeNullDefault
employeeIduuidNOT NULL
leaveTypeUSER-DEFINEDNOT NULL
startDatedateNOT NULL
endDatedateNOT NULL
reasontextNOT NULL
statusUSER-DEFINEDNOT NULL'pending'
approvedByvarchar()NULL
approvedAttimestampNULL
rejectionReasonvarchar()NULL
isHalfDaybooleanNOT NULLfalse
halfDayPeriodUSER-DEFINEDNULL
attachmentsjsonbNULL
organizationIduuidNOT NULL

References: employeeIdemployees, organizationIdorganizations

Unique:

  • id

leave_entitlement_rules

ColumnTypeNullDefault
yearsOfServiceMinintegerNOT NULL
yearsOfServiceMaxintegerNULL
entitledDaysnumeric(4,1)NOT NULL
accrualTypeUSER-DEFINEDNOT NULL'annual'
maxDaysnumeric(4,1)NULL
descriptionvarchar(200)NULL
sortOrderintegerNOT NULL0
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • organizationId, yearsOfServiceMin
  • id

leave_of_absence_records

ColumnTypeNullDefault
employeeIduuidNOT NULL
reasonvarchar()NOT NULL
startDatedateNOT NULL
expectedReturnDatedateNULL
actualReturnDatedateNULL
statusUSER-DEFINEDNOT NULL'active'
processedByvarchar()NULL
notesvarchar()NULL
organizationIduuidNOT NULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • id

Incentives & treatments

fixed_incentives

ColumnTypeNullDefault
employeeIduuidNOT NULL
yearintegerNOT NULL
monthintegerNOT NULL
incentiveTypevarchar()NOT NULL
positionvarchar()NULL
statusUSER-DEFINEDNOT NULL'pending'
approvedByvarchar()NULL
approvedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL
chainIduuidNOT NULL
versionintegerNOT NULL1
supersededAttimestampNULL
categoryUSER-DEFINEDNOT NULL'other'
workDatedateNULL
unitCountintegerNOT NULL1
unitPricenumeric(15,2)NOT NULL0
totalAmountnumeric(15,2)NOT NULL0
splitRationumeric(5,2)NULL
metadatajsonbNULL
sessionIduuidNULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • chainId, version
  • id

incentive_presets

ColumnTypeNullDefault
codevarchar()NOT NULL
namevarchar()NOT NULL
descriptiontextNULL
unitPricenumeric(15,2)NOT NULL0
isActivebooleanNOT NULLtrue
sortOrderintegerNOT NULL0
categoryIduuidNULL
organizationIduuidNOT NULL

References: organizationIdorganizations, categoryIdincentive_preset_categories

Unique:

  • id
  • organizationId, code WHERE (deletedAt IS NULL)

incentive_preset_categories

ColumnTypeNullDefault
codevarchar()NULL
namevarchar()NOT NULL
descriptiontextNULL
applicableTeamsjsonbNULL
isActivebooleanNOT NULLtrue
sortOrderintegerNOT NULL0
organizationIduuidNOT NULL
isAttendanceVerifiablebooleanNOT NULLfalse

References: organizationIdorganizations, organizationIdorganizations

Unique:

  • id

treatment_categories

ColumnTypeNullDefault
codevarchar()NULL
namevarchar()NOT NULL
descriptiontextNULL
hospitalRationumeric(5,2)NOT NULL0.5
therapistRationumeric(5,2)NOT NULL0.5
isActivebooleanNOT NULLtrue
sortOrderintegerNOT NULL0
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id

treatment_items

ColumnTypeNullDefault
codevarchar()NULL
namevarchar()NOT NULL
ratiovarchar()NOT NULL'1:1'
unitPricenumeric(15,2)NOT NULL0
isActivebooleanNOT NULLtrue
sortOrderintegerNOT NULL0
organizationIduuidNOT NULL
treatmentCategoryIduuidNOT NULL

References: organizationIdorganizations, treatmentCategoryIdtreatment_categories

Unique:

  • id

Sheets (workbook)

sheet_views

ColumnTypeNullDefault
organizationIduuidNOT NULL
yearintegerNOT NULL
monthintegerNOT NULL
namevarchar(120)NOT NULL
visibilityvarchar(16)NOT NULL
createdByuuidNOT NULL
filtersjsonbNOT NULL
columnLayoutjsonbNOT NULL'[]'
groupByjsonbNOT NULL'["employeeId"]'
sortjsonbNULL
descriptiontextNULL
lockedAttimestampNULL
lockedByuuidNULL
viewKindvarchar(16)NOT NULL'row'
groupIdvarchar(64)NULL
autoPopulatejsonbNULL
computeConfigjsonbNULL
lastMaterializedAttimestampNULL
slugvarchar(64)NULL
rowBasisvarchar(16)NULL

References: organizationIdorganizations

Unique:

  • id
  • organizationId, year, month, slug WHERE ((slug IS NOT NULL) AND (deletedAt IS NULL))

sheet_rows

ColumnTypeNullDefault
sheetViewIduuidNOT NULL
employeeIduuidNULL
sourcevarchar(8)NOT NULL'manual'
sourceAllowanceRecordIduuidNULL
sourceDeductionRecordIduuidNULL
sourceOvertimeRecordIduuidNULL
sourceFixedIncentiveIduuidNULL
sortOrderintegerNOT NULL0
sourceTablevarchar(32)NULL
sourceRecordIduuidNULL

References: sourceOvertimeRecordIdovertime_records, employeeIdemployees, sourceFixedIncentiveIdfixed_incentives, sheetViewIdsheet_views, sourceDeductionRecordIddeduction_records, sourceAllowanceRecordIdallowance_records

Unique:

  • id
  • sheetViewId, sourceFixedIncentiveId WHERE ((sourceFixedIncentiveId IS NOT NULL) AND (deletedAt IS NULL))
  • sheetViewId, sourceDeductionRecordId WHERE ((sourceDeductionRecordId IS NOT NULL) AND (deletedAt IS NULL))
  • sheetViewId, sourceAllowanceRecordId WHERE ((sourceAllowanceRecordId IS NOT NULL) AND (deletedAt IS NULL))
  • sheetViewId, sourceOvertimeRecordId WHERE ((sourceOvertimeRecordId IS NOT NULL) AND (deletedAt IS NULL))
  • sheetViewId, sourceTable, sourceRecordId WHERE ((sourceTable IS NOT NULL) AND (sourceRecordId IS NOT NULL) AND (deletedAt IS NULL))

sheet_cells

ColumnTypeNullDefault
sheetRowIduuidNOT NULL
columnKeyvarchar(64)NOT NULL
kindvarchar(12)NOT NULL
literalValuejsonbNULL
refAllowanceRecordIduuidNULL
refDeductionRecordIduuidNULL
refOvertimeRecordIduuidNULL
refFixedIncentiveIduuidNULL
formulaExpressiontextNULL
computedValuejsonbNULL
computedAttimestampNULL
inputSnapshotjsonbNULL

References: sheetRowIdsheet_rows, refAllowanceRecordIdallowance_records, refDeductionRecordIddeduction_records, refOvertimeRecordIdovertime_records, refFixedIncentiveIdfixed_incentives

Unique:

  • sheetRowId, columnKey WHERE (deletedAt IS NULL)
  • id

sheet_templates

ColumnTypeNullDefault
organizationIduuidNULL
isSystembooleanNOT NULLfalse
namevarchar(120)NOT NULL
descriptiontextNULL
viewKindvarchar(16)NOT NULL'row'
filtersjsonbNOT NULL'{}'
columnLayoutjsonbNOT NULL'[]'
groupIdvarchar(64)NULL
sortOrderintegerNOT NULL100
createdByvarchar(64)NULL

References: organizationIdorganizations

Unique:

  • id

Settlement & subsidy

year_end_settlements

ColumnTypeNullDefault
employeeIduuidNOT NULL
settlementYearintegerNOT NULL
applicationDatedateNULL
applicationMonthintegerNULL
statusUSER-DEFINEDNOT NULL'pending'
calculatedByvarchar()NULL
calculatedAttimestampNULL
approvedByvarchar()NULL
approvedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL
chainIduuidNOT NULL
versionintegerNOT NULL1
supersededAttimestampNULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • chainId, version
  • id

resignation_records

ColumnTypeNullDefault
employeeIduuidNOT NULL
resignationDatedateNOT NULL
statusUSER-DEFINEDNOT NULL'pending'
reasonvarchar()NULL
processedByvarchar()NULL
processedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL
chainIduuidNOT NULL
versionintegerNOT NULL1
supersededAttimestampNULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • chainId, version
  • id

education_subsidies

ColumnTypeNullDefault
employeeIduuidNOT NULL
courseNamevarchar()NOT NULL
paymentDatedateNOT NULL
receiptVerifiedbooleanNOT NULLfalse
statusUSER-DEFINEDNOT NULL'pending'
approvedByvarchar()NULL
approvedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL
chainIduuidNOT NULL
versionintegerNOT NULL1
supersededAttimestampNULL

References: employeeIdemployees, organizationIdorganizations

Unique:

  • id
  • chainId, version

grade_promotion_requests

ColumnTypeNullDefault
employeeIduuidNOT NULL
organizationIduuidNOT NULL
currentGradeIduuidNULL
currentGradeintegerNOT NULL
nextGradeintegerNOT NULL
nextGradeIduuidNULL
promotionDatedateNOT NULL
promotionTypevarchar()NOT NULL'hire_anniversary'
yearsOfServiceintegerNOT NULL0
currentBaseSalarynumeric(15,2)NOT NULL0
newBaseSalarynumeric(15,2)NOT NULL0
currentHobongAmountnumeric(15,2)NOT NULL0
newHobongAmountnumeric(15,2)NOT NULL0
statusvarchar()NOT NULL'pending'
approvedByuuidNULL
approvedAttimestampNULL
rejectedReasontextNULL
notestextNULL

References: organizationIdorganizations, employeeIdemployees, currentGradeIdsalary_grades, nextGradeIdsalary_grades

Unique:

  • id

certificate_issuances

ColumnTypeNullDefault
employeeIduuidNOT NULL
certificateNumbervarchar()NULL
purposevarchar()NOT NULL
organizationIduuidNOT NULL
statusUSER-DEFINEDNOT NULL'pending'
approvedByvarchar()NULL
approvedAttimestampNULL
rejectedReasonvarchar()NULL
certificateHtmltextNULL
templateIduuidNULL

References: templateIddocument_templates, organizationIdorganizations, employeeIdemployees

Unique:

  • id

Nurse scheduler

nurse_profiles

ColumnTypeNullDefault
employeeIduuidNOT NULL
workTypeUSER-DEFINEDNOT NULL
wardIduuidNOT NULL
isHeadNursebooleanNOT NULLfalse
organizationIduuidNOT NULL
metadatajsonbNULL

References: employeeIdemployees, organizationIdorganizations, wardIdwards

Unique:

  • id
  • employeeId, wardId WHERE (deletedAt IS NULL)

nurse_schedules

ColumnTypeNullDefault
wardIduuidNOT NULL
yearintegerNOT NULL
monthintegerNOT NULL
statusUSER-DEFINEDNOT NULL'draft'
confirmedByvarchar()NULL
confirmedAttimestampNULL
publishedAttimestampNULL
organizationIduuidNOT NULL
settingsjsonbNULL
metadatajsonbNULL
confirmedByEmployeeIduuidNULL
startDatedateNULL
endDatedateNULL

References: wardIdwards, confirmedByEmployeeIdemployees, organizationIdorganizations

Unique:

  • id
  • wardId, year, month, organizationId
  • wardId, year, month, startDate, organizationId WHERE (deletedAt IS NULL)

nurse_schedule_entries

ColumnTypeNullDefault
scheduleIduuidNOT NULL
employeeIduuidNOT NULL
datedateNOT NULL
assignmentTypeUSER-DEFINEDNOT NULL
shiftIduuidNULL
isAiGeneratedbooleanNOT NULLfalse
isManualOverridebooleanNOT NULLfalse
notestextNULL

References: employeeIdemployees, shiftIdshifts, scheduleIdnurse_schedules

Unique:

  • scheduleId, employeeId, date
  • id

nurse_preferences

ColumnTypeNullDefault
employeeIduuidNOT NULL
yearintegerNOT NULL
monthintegerNOT NULL
wardIduuidNOT NULL
organizationIduuidNOT NULL
vacationDatesjsonbNOT NULL'[]'
restrictedDatesjsonbNOT NULL'[]'
unavailableDatesjsonbNOT NULL'[]'
notestextNULL
submittedAttimestampNULL
statusUSER-DEFINEDNOT NULL'draft'

References: wardIdwards, employeeIdemployees, organizationIdorganizations

Unique:

  • id
  • employeeId, year, month

work_type_change_requests

ColumnTypeNullDefault
employeeIduuidNOT NULL
currentWorkTypeUSER-DEFINEDNOT NULL
requestedWorkTypeUSER-DEFINEDNOT NULL
reasontextNOT NULL
effectiveDatedateNULL
statusUSER-DEFINEDNOT NULL'pending'
approvedByvarchar()NULL
approvedAttimestampNULL
rejectionReasontextNULL
organizationIduuidNOT NULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • id

wards

ColumnTypeNullDefault
codevarchar()NOT NULL
namevarchar()NOT NULL
descriptiontextNULL
displayOrderintegerNOT NULL0
isActivebooleanNOT NULLtrue
schedulingConfigjsonbNULL
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • organizationId, code WHERE (deletedAt IS NULL)
  • id

ward_daily_records

ColumnTypeNullDefault
wardIduuidNOT NULL
datedateNOT NULL
patientCountintegerNOT NULL0
updatedByIduuidNULL
organizationIduuidNOT NULL
notestextNULL

References: updatedByIdemployees, organizationIdorganizations, wardIdwards

Unique:

  • id
  • wardId, date, organizationId

General affairs

general_affairs_notices

ColumnTypeNullDefault
titlevarchar()NOT NULL
contenttextNOT NULL
categoryUSER-DEFINEDNOT NULL
priorityUSER-DEFINEDNOT NULL'normal'
publishedAttimestampNULL
expiresAttimestampNULL
isPublishedbooleanNOT NULLfalse
createdByIdvarchar()NOT NULL
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id

notice_acknowledgments

ColumnTypeNullDefault
noticeIduuidNOT NULL
employeeIduuidNOT NULL
organizationIduuidNOT NULL
acknowledgedAttimestampNOT NULLnow()

References: employeeIdemployees, noticeIdgeneral_affairs_notices, organizationIdorganizations

Unique:

  • noticeId, employeeId
  • id

mandatory_trainings

ColumnTypeNullDefault
namevarchar()NOT NULL
categoryUSER-DEFINEDNOT NULL
legalBasisvarchar()NULL
frequencyUSER-DEFINEDNOT NULL
requiredHoursnumeric(5,1)NULL
targetAudiencevarchar()NULL
penaltyAmountnumeric(15,2)NULL
penaltyDescriptionvarchar()NULL
descriptiontextNULL
isActivebooleanNOT NULLtrue
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id

training_completions

ColumnTypeNullDefault
mandatoryTrainingIduuidNOT NULL
employeeIduuidNOT NULL
completedDatedateNOT NULL
expiryDatedateNOT NULL
certificateNumbervarchar()NULL
hoursnumeric(5,1)NULL
providervarchar()NULL
statusUSER-DEFINEDNOT NULL'completed'
notesvarchar()NULL
organizationIduuidNOT NULL

References: employeeIdemployees, organizationIdorganizations, mandatoryTrainingIdmandatory_trainings

Unique:

  • id

recurring_tasks

ColumnTypeNullDefault
titlevarchar()NOT NULL
descriptiontextNULL
categoryUSER-DEFINEDNOT NULL
frequencyUSER-DEFINEDNOT NULL
assignedTovarchar()NULL
dueDayintegerNULL
isActivebooleanNOT NULLtrue
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id

recurring_task_executions

ColumnTypeNullDefault
recurringTaskIduuidNOT NULL
scheduledDatedateNOT NULL
completedDatedateNULL
completedByvarchar()NULL
statusUSER-DEFINEDNOT NULL'pending'
notestextNULL
organizationIduuidNOT NULL

References: organizationIdorganizations, recurringTaskIdrecurring_tasks

Unique:

  • id

task_checklist_items

ColumnTypeNullDefault
recurringTaskIduuidNOT NULL
titlevarchar()NOT NULL
sortOrderintegerNOT NULL0
isRequiredbooleanNOT NULLtrue
organizationIduuidNOT NULL

References: recurringTaskIdrecurring_tasks, organizationIdorganizations

Unique:

  • id

checklist_completions

ColumnTypeNullDefault
taskChecklistItemIduuidNOT NULL
taskExecutionIduuidNOT NULL
isCompletedbooleanNOT NULLfalse
completedByvarchar()NULL
completedAttimestampNULL
notesvarchar()NULL
organizationIduuidNOT NULL

References: taskChecklistItemIdtask_checklist_items, organizationIdorganizations, taskExecutionIdrecurring_task_executions

Unique:

  • id

Inventory

inventory_categories

ColumnTypeNullDefault
codevarchar()NULL
namevarchar()NOT NULL
descriptiontextNULL
isActivebooleanNOT NULLtrue
sortOrderintegerNOT NULL0
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id

inventory_items

ColumnTypeNullDefault
namevarchar()NOT NULL
codevarchar()NULL
categoryIduuidNOT NULL
quantityintegerNOT NULL0
unitvarchar()NOT NULL'개'
minimumStockintegerNOT NULL0
expirationDatedateNULL
locationvarchar()NULL
suppliervarchar()NULL
isRefundCandidatebooleanNOT NULLfalse
refundMemotextNULL
refundQuantityintegerNULL
notestextNULL
isActivebooleanNOT NULLtrue
organizationIduuidNOT NULL

References: organizationIdorganizations, categoryIdinventory_categories

Unique:

  • id

Notifications

notification_events

ColumnTypeNullDefault
organizationIduuidNOT NULL
actorIduuidNULL
targetEmployeeIduuidNULL
typeUSER-DEFINEDNOT NULL
actionUSER-DEFINEDNOT NULL
titlevarchar()NOT NULL
messagetextNOT NULL
referenceTypevarchar()NULL
referenceIduuidNULL
groupKeyvarchar()NULL
metadatajsonbNULL

Unique:

  • id

notification_deliveries

ColumnTypeNullDefault
eventIduuidNOT NULL
recipientIduuidNOT NULL
channelUSER-DEFINEDNOT NULL'in_app'
statusUSER-DEFINEDNOT NULL'pending'
isSeenbooleanNOT NULLfalse
isReadbooleanNOT NULLfalse
isDismissedbooleanNOT NULLfalse
seenAttimestampNULL
readAttimestampNULL
sentAttimestampNULL

References: recipientIdemployees, eventIdnotification_events

Unique:

  • id

notification_preferences

ColumnTypeNullDefault
employeeIduuidNOT NULL
organizationIduuidNOT NULL
eventTypevarchar()NOT NULL'*'
channelUSER-DEFINEDNOT NULL'in_app'
enabledbooleanNOT NULLtrue

References: organizationIdorganizations, employeeIdemployees

Unique:

  • employeeId, eventType, channel
  • id

notification_mute_settings

ColumnTypeNullDefault
employeeIduuidNOT NULL
organizationIduuidNOT NULL
muteTypeUSER-DEFINEDNOT NULL
muteTargetIduuidNULL
eventTypeUSER-DEFINEDNULL
mutedAttimestampNOT NULLnow()
expiresAttimestampNULL

References: employeeIdemployees

Unique:

  • id
  • employeeId, muteType, eventType WHERE (eventType IS NOT NULL)
  • employeeId, muteType, muteTargetId WHERE (muteTargetId IS NOT NULL)

Communications & docs

conversations

ColumnTypeNullDefault
typeUSER-DEFINEDNOT NULL
titlevarchar()NULL
createdByvarchar()NOT NULL
lastMessageAttimestampNULL
lastMessageContentvarchar()NULL
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id

conversation_members

ColumnTypeNullDefault
conversationIduuidNOT NULL
employeeIduuidNOT NULL
joinedAttimestampNOT NULLnow()
lastReadAttimestampNULL
unreadCountintegerNOT NULL0
customNamevarchar()NULL
roleUSER-DEFINEDNOT NULL'member'
leftAttimestampNULL
statusUSER-DEFINEDNOT NULL'active'

References: conversationIdconversations, employeeIdemployees

Unique:

  • conversationId, employeeId
  • id

messages

ColumnTypeNullDefault
conversationIduuidNOT NULL
senderIduuidNULL
contenttextNOT NULL
typeUSER-DEFINEDNOT NULL'text'
readByjsonbNULL
organizationIduuidNOT NULL
attachmentsjsonbNULL

References: conversationIdconversations, senderIdemployees, organizationIdorganizations

Unique:

  • id

documents

ColumnTypeNullDefault
employeeIduuidNOT NULL
filenamevarchar()NOT NULL
originalFilenamevarchar()NOT NULL
mimeTypevarchar()NOT NULL
fileSizeintegerNOT NULL
storagePathvarchar()NOT NULL
categoryUSER-DEFINEDNOT NULL'other'
documentTypevarchar()NOT NULL
statusUSER-DEFINEDNOT NULL'processing'
reviewedByvarchar()NULL
reviewedAttimestampNULL
notesvarchar()NULL
metadatajsonbNULL
organizationIduuidNOT NULL

References: organizationIdorganizations, employeeIdemployees

Unique:

  • id

document_templates

ColumnTypeNullDefault
codevarchar(50)NOT NULL
namevarchar()NOT NULL
bodyTemplatetextNOT NULL
cssTemplatetextNULL
isActivebooleanNOT NULLtrue
sortOrderintegerNOT NULL0
descriptionvarchar()NULL
organizationIduuidNOT NULL

References: organizationIdorganizations

Unique:

  • id
  • organizationId, code WHERE (deletedAt IS NULL)

e_sign_records

ColumnTypeNullDefault
organizationIduuidNOT NULL
employeeIduuidNOT NULL
sentByIduuidNOT NULL
herebyTemplateIdintegerNOT NULL
herebyContractIdintegerNULL
herebyRedirectUrltextNULL
templateNameSnapshotvarchar()NOT NULL
recipientNameSnapshotvarchar()NOT NULL
recipientEmailSnapshotvarchar()NOT NULL
recipientPhoneSnapshotvarchar()NULL
errorMessagetextNULL
statusUSER-DEFINEDNOT NULL'sending'
sentAttimestampNOT NULL
signedAttimestampNULL

References: employeeIdemployees, sentByIdemployees, organizationIdorganizations

Unique:

  • herebyContractId WHERE (herebyContractId IS NOT NULL)
  • id

Integration / system

secom_events

ColumnTypeNullDefault
eventDatetimevarchar(20)NOT NULL
terminalIdvarchar(100)NOT NULL
cardNumbervarchar(100)NULL
employeeNumbervarchar(100)NOT NULL
employeeNamevarchar(200)NULL
rawEventTypevarchar(50)NULL
authTypevarchar(10)NULL
ackModevarchar(10)NULL
ackTimevarchar(20)NULL
rawDatajsonbNULL
eventTypeUSER-DEFINEDNOT NULL'unknown'
statusUSER-DEFINEDNOT NULL'pending'
errorMessagetextNULL
processedAttimestamp with time zoneNULL
organizationIduuidNOT NULL
employeeIduuidNULL
attendanceIduuidNULL
pulledAttimestamp with time zoneNOT NULLnow()

References: attendanceIdattendances, employeeIdemployees, organizationIdorganizations

Unique:

  • id

secom_sync_state

ColumnTypeNullDefault
sourceKeyvarchar(50)NOT NULL
schemaNamevarchar(100)NOT NULL
organizationIduuidNOT NULL
enabledbooleanNOT NULLtrue
lastGatewayCreatedAttimestampNOT NULL'1970-01-01 00:00:00'
lastRunAttimestamp with time zoneNULL
lastPulledCountintegerNOT NULL0

References: organizationIdorganizations

Unique:

  • sourceKey

ota_bundles

ColumnTypeNullDefault
appIdvarchar()NOT NULL
platformUSER-DEFINEDNOT NULL
bundleVersionvarchar()NOT NULL
minNativeVersionvarchar()NOT NULL
channelvarchar()NOT NULL'production'
s3Keyvarchar()NOT NULL
downloadUrlvarchar()NOT NULL
checksumvarchar()NOT NULL
fileSizeintegerNOT NULL
releaseNotestextNULL
isActivebooleanNOT NULLtrue
expiresAttimestampNULL
createdByvarchar()NULL

Unique:

  • s3Key
  • id
  • appId, platform, bundleVersion

migrations

ColumnTypeNullDefault
timestampbigintNOT NULL
namevarchar()NOT NULL

Unique:

  • id

Regenerate

bash
# Re-extract metadata from the live DB (uses .env DB_*):
cd packages/database && \
  psql ... -tA -c "<columns query>" > /tmp/_cols.txt && \
  psql ... -tA -c "<fks query>" > /tmp/_fks.txt && \
  psql ... -tA -c "<unique-idx query>" > /tmp/_uniq.txt
# Then re-run the Python generator (see git history of this file).

Source of truth: the live database schema (TypeORM migrations). Entities + migrations: packages/database/src/entities/, packages/database/src/migrations/.