Skip to content

feat(db): the room trigger takes a part with a row per room - #695

Merged
mindsers merged 3 commits into
mainfrom
feat/rooms-r4-4a-trigger
Nov 28, 2026
Merged

mindsers merged 3 commits into
mainfrom
feat/rooms-r4-4a-trigger

Conversation

@mindsers

@mindsers mindsers commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Parallel rooms R4, PR 4a: the migration that comes before the writers. It is safe with the code running today, which this PR doesn't change.

Migration 20261204090000_rooms_writers replaces item_room(), nothing else.

  • A part with a row per room (R4's shape):
    • A write of the item's people or conflict reaches its main room's row only, and only the columns that changed. This is what a version still running does. Before, it updated "its one row" across every row and hit unique (itemId, roomId).
    • A write of its track / trackOrder is ignored: its rows are its rooms.
    • Moved to another programme (scheduleId, which means another meeting): refused with an exception. No writer does it today, and remapping its rows by name could rename the target's unnamed main room and drop a room's person, so a future writer finds out instead. Leaving its programme (no schedule, or a services schedule), which would take every room's people with its rows, is refused the same way.
  • A part in one room (today's copies, a part for everyone): unchanged except that an UPDATE copies only the people and conflict it changed. A conflict refresh by a version still running then keeps the row's newer people, which R4's writers write on the row alone. An INSERT still copies everything, and the room-follows-track behaviour and pruning are kept.

Contract: who holds what is unchanged. Every part holds one row today, and the row equals the item's columns.

Not here: Item.updatedAt following a row write. A trigger would stamp the transaction's start time, earlier than the app's own updatedAt: it would break the EventPart→Item copy test's equality and move the calendar-feed references, which freeze time. The writers (PR 4b) touch the item themselves, on the app's clock.

Tests: rooms-writers integration, on the rooms fixture's meeting with a row per room:

  • old-style write of a new speaker → main row only;
  • old-style conflict → main row only, both rows' people kept;
  • old-style track write → no failure, still two rows;
  • moving it to another meeting's programme is refused, and so is leaving its programme for its meeting's services (both rows kept);
  • a one-room part whose row holds a newer speaker than its item keeps it when the item is flagged.

All six failed before the migration (unique violations, wrong values) and pass after.

Checked like CI: prisma migrate deploy on the test database, then the whole integration suite on today's code with the new trigger: 188 files, references included, all pass.

Next, PR 4b: assignPart / unassignPart / refreshConflictFlags / deleteExternalSpeaker write the room's row and touch the item. It merges only after #690–#694, which move every reader to the rows.

Parallel rooms R4, the migration before the writers (no dual-write). The
Item_room trigger:
- on a part with a row per room, puts a write of the item's people (a version
  still running) on its main room's row alone, ignores its track, and moves
  its rows with it to another programme (by room name) without failing;
- on a part in one room, takes only the people and conflict a write changed,
  so a conflict refresh by a running version keeps the row's newer people.
Who holds what is unchanged; today's code runs as before with it (every
part holds one row).
No writer moves one; remapping its rows by name could rename the target's
unnamed main room and drop a room's person on the unique key. Raised, so a
future writer learns it rather than losing someone.
As a move is: leaving it (no schedule, or a services schedule) would take
every room's people with its rows. No writer does it.
@mindsers
mindsers merged commit df0b1f0 into main Nov 28, 2026
7 checks passed
@mindsers
mindsers deleted the feat/rooms-r4-4a-trigger branch November 28, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant