Repository navigation
feat(events): give absences a table of their own, written alongside the day-off events - #566
Merged
Merged
Conversation
… events Absence: dates, note, the person's record when the account that declared it has one, the account otherwise (CHECK one of the two), the event it was copied from. Tenant policy forced. Every day-off event is copied once, as it is; a second run copies only what is new. Nothing reads it yet.
…ted during the origin rollout Its recurring-events job wrote the default « manual » while the origin migration rolled out, so those meetings stopped moving with their template. Only events created after that migration, empty, without an author and never written since: a hand-made event whose account was deleted keeps « manual ».
Declaring an absence creates the day-off event and its Absence row in one transaction, the person's record when the account has one; deleting it removes both. The readers still read the events.
Absence.accountId is Restrict: an account without a record takes its rows with it, and an account with a record — refused while it has absences — drops rows whose event a previous version deleted without them.
The readers move to the Absence table before the archive carries it, so a restored day-off event gets its row now: the restored account's record when it has one, as the migration does.
Absence.accountId is Restrict and no foreign key ties a row to its event, so reseeding the demo failed on the accounts. Checked by running the seed twice on a scratch database.
… is linked or an event deleted Linking an account to a new record gives the record the absences the account declared without one, as its day-off events already follow it. Deleting events, one or in bulk, also deletes the Absence row of any absence among them: no foreign key ties a row to its event.
…edges The delete test checks the row existed first; isolation counts both sides and refuses a write into another congregation; the migration leaves out an absence without an author and an event pointing at another congregation's template, and copies that congregation's own; an account whose only absence row lost its event can still be deleted; a refused delete leaves the row.
… are The migration says what the previous version does meanwhile and that a later migration reconciles; the Absence doc sits above its own model again and says its record is the one at write time; account deletion and createDayOff docs mention the rows. A restored absence whose account is missing now fails the import instead of being mis-owned.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 1a of the event schedules plan (#533): absences get a table of their own. Nothing reads it yet; readers switch over in 1b and 1c.
What changes
Absencestores the dates, a note, the person's record when the account that declared it has one, and the account otherwise. A CHECK requires one of the two. Each row also keeps the day-off event it was copied from (legacyEventId). The standard tenant policy applies and is forced.accountIdisRestrict: deleting an account has to let go of its absences explicitly.createdAtkept, owner's record looked up through the account. Run again, it copies only what is new.Absencerow in one transaction, and deleting it removes both. Every reader still reads the events.Absencerows. The refusal for an account with a record and absences stays until absences belong to the record (decided).jobto the empty meetings the previous version created whileEvent.originrolled out (fix(events): record who created each event, and delete accounts without a foreign-key error #564). It is limited to events created after that migration finished and never written since, so a hand-made event whose author's account was deleted keepsmanual.Rollout
The previous version, running on this schema, still writes day-off events only. Absences it creates during the rollout get no
Absencerow, and absences it deletes leave their row behind. A later migration copies the missing rows and drops the orphaned ones before the events are dropped; the backfill is idempotent for that reason. Account deletion already clears rows left behind this way, so they can't block it.Meanwhile, the previous version can't delete an account without a record that has absences: the new rows name the account, which is
Restrict. The new version releases them first.References
Untouched. No reader changed, and every reference file comes back byte-identical.
Verification
job;