Skip to content

Storage

The attendance store keeps two things for each tenant. One is everything a ledger is worked out from. The other is the ledgers last worked out from it. Read this page to know what is kept, what is never changed, and what you can safely send twice.

Facts per person, kept once Setup tenant or person, revisions Policy layers revisions, never changed Policy packages versions, adoptions Store per tenant, in Postgres work out Ledgers derived, last result kept
Nothing kept is ever rewritten. A change is a new fact or a new revision. Ledgers are results. They are worked out again whenever what they came from changes.

The attendance API puts setup, layers, packages and facts in. It reads facts and kept ledgers out. Deleting a tenant deletes everything kept of it, its delivery keys included.

Facts are kept per person and only ever added. They are punches, corrections, labor entries, approvals, period closes, accrual adjustments, schedule overrides, employment changes, notes on exceptions and leave requests.

  • Sending the same fact again changes nothing. A fact recorded with an id already kept and the same content is ignored. So a sender may retry after a lost reply without making a second punch. An approval or a close sent twice is also kept once.
  • The same id with other content is refused. A fact is never rewritten. To change one, record a new fact, such as a correction.

A fact has two fields about who put it in:

  • by is what its sender says of itself. Examples are the user who decided and the person who noted.
  • via is who put it in, as the server saw it. The server sets it, whatever the sender says. A via sent is not kept, as a stored is not.

The via value depends on how the fact came in:

  • The login’s user or the token’s name, for a fact posted through the API (POST .../people/{person}/facts and the routes that record a leave request, a decision or a note).
  • delivery:<key id>, for a punch delivered with a delivery key.
  • None, for a fact of a tenant document loaded without it.

GET .../people/{person}/facts shows it, and a tenant document carries it. It is no part of what a fact says. The same fact put in again by another door is the same fact, and the first via stands.

A fact names days from 1900-01-01 through 2199-12-31. That covers a punch, a leave day, a close and an employment change. One outside them is refused where it is recorded, saying the day.

A labor entry’s quantity is at most 2^40 (1,099,511,627,776) either way, in its measure’s unit. That is about 35 years of milliseconds, or 11 billion in minor units of money. A larger one is refused, naming the entry and its measure. So the sums a ledger makes of many entries stay far inside a 64-bit number. A step’s sum that would pass one fails the person’s ledger, naming the measure. It is never wrapped.

Setup is kept as items, each by kind and id, for the tenant or for one person. Every change to an item is a new revision. The newest is in force. Taking an item away is a revision too. Nothing is overwritten.

Kind
dimension, assignment, implicationLabor context.
shift, shift_definition, holidaySchedules.
category, measure, ratePay categories, measures and rates.
approval_rule, accrual_categoryApprovals, accruals.
defaultsValues work takes when nothing else gives them: the tenant’s, or the person’s.
zoneThe time zone the person’s work is counted in. It is a name (from the beginning), or { "zone": "America/New_York", "from": "2026-10-08" } from a workday on. An instant is read in the zone in force at it, so a move never reinterprets earlier time. A person at a work location is worked out in the location’s zone.

A person’s setup is their tenant’s with their own over it. Their items are added to the tenant’s. Their defaults and zone replace the tenant’s. A person with no zone at all is refused, never counted in a guessed zone.

Which policy layers apply to a person is not setup. Each layer’s eligibility rule decides, for the person on each day. The tenant’s employers, hierarchies, organizations and locations are kept beside the setup. Where a person is in them comes from their employment facts.

A policy layer is kept by its id and revision, and once kept never changes. A change to a layer is its next revision. Sending the same layer again changes nothing. A different layer under a revision already kept is refused.

Policy packages are kept as versions, a tenant’s own or shared across the install. Each keeps its source, layers and scenarios and how its scenarios ran. A version whose scenarios fail is kept but never used. A published version never changes.

A tenant’s adoptions are kept in order. Each follows a major version or is pinned to one. The version in force on a day is the highest one its adoption admits that is in force that day.

The store keeps one ledger per person, pay period and side, as last worked out. A ledger is a result. It is worked out again whenever anything it came from changes (recalculation). A write and the recalculation it causes are saved together.

Some results are kept for good:

  • Closed periods. Each closed period keeps a record of the ledger as it stood at its close, with its sums. A closed period is read from that record until it is reopened.
  • Exceptions. The exceptions of every kept pay ledger are listed by the follow-up list. The list also shows where following each up stands.
  • Exports. Each payroll export is recorded (exporter, side, period, whose time, by whom, when, how it ended). The record has enough to list whose time changed since. The exported file itself is not kept.
  • Unreadable punches. Deliveries that could not be read as punches are kept as they came, with why (a punch that cannot be read).

An instance running the engine keeps the attendance tables in Connect’s database, through its connections. Their schema history is kept in a table of its own, attendance_schema_history, apart from Connect’s. Each instance brings the schema up to date as it starts. Instances starting together take turns, and the later ones find the work done.

Old and new versions side by side. The attendance schema changes in steps that keep what the previous version reads and writes (expand, then contract a release later). Each step says in its file which older schema may run after it. An instance records that in att_schema_compat when it brings the schema in.

Suppose an instance of an older version starts on a database that a newer one changed. It runs if every change it does not know says it may. This is a rolling upgrade or a rollback. The instance logs that it does. If one change does not say so, or the database predates the record, it refuses to start. It says which change and what to run instead.

Bringing the schema in waits for another instance’s changes as long as it takes. But a change gives up on a table the live work holds after 3 seconds, and the start is tried again. The connection’s own limits are put back when it is done.

The engine’s event log and its sinks are kept apart from Connect’s. So Connect’s events and Time and Attendance’s never mix (events and sinks).

Plan backups with both in mind. Connect’s data is many small writes kept for days. Time and Attendance’s is payroll data, kept as long as the tenant exists. See operations for running Postgres.