Skip to content

refactor: move notification and staff tables into their modules - #177

Merged
axelhamil merged 2 commits into
developfrom
refactor/173-module-schemas-notification-staff
Nov 10, 2026
Merged

axelhamil merged 2 commits into
developfrom
refactor/173-module-schemas-notification-staff

Conversation

@axelhamil

Copy link
Copy Markdown
Owner
  • notification.ts moves to modules/notifications/schemas/, staff.ts to modules/admin/schemas/, kit tables imported through @packages/drizzle/schema/*
  • packages/drizzle re-exports no business table and drops its @packages/events dependency: src/schema/ now holds kit tables only
  • The fan-out reads its staff audience through IStaffRecipientsReader, declared by notifications, served by the host query apps/api/src/queries/staff-recipients.query.ts (same SQL, same unit of work)
  • Owners import their schema relatively; host services, routes, seeds and check scripts through @modules/<owner>/schemas/<file>
  • Database untouched: db:generate empty, pg_dump --schema-only identical to develop, a probe column was detected by the negative test
  • Every real-database step of CI green on a scratch database (23/23, db:seed included), api image builds

Closes #173

The notification tables now live in modules/notifications/schemas and the
staff tables in modules/admin/schemas, importing the kit tables through the
@packages/drizzle sub-paths. packages/drizzle stops re-exporting them and no
longer depends on @packages/events, so its schema folder holds kit tables
only.

The notification fan-out read the staff tables of the admin module. It now
asks for its staff audience through IStaffRecipientsReader, a port the
notifications module declares, served by a host query in
apps/api/src/queries and bound in the container. The query keeps the same
SQL and runs in the fan-out's unit of work, so the audience is read in the
transaction that inserts the notifications.

Owners import their schema relatively; host services, routes, seeds and
check scripts go through the module schemas export. The database is
untouched, db:generate finds no change and db:push yields the same schema
as develop.

Closes #173
@axelhamil axelhamil added the maintenance Tooling, CI, docs or refactor with no user-facing change label Nov 10, 2026
@axelhamil axelhamil self-assigned this Nov 10, 2026
The fan-out bound one parameter per staff recipient, so an audience past
the 65,535 parameters of a Postgres bind message failed every delivery,
where develop read it in a subquery. The ids now travel as a single text
array, which also keeps the statement text stable whatever the audience
size; an empty list still yields no row.

A failed staff read was captured twice, once by the host query that owns
the I/O and once by the subscriber when the failure came back as an
AppErrorException. The subscriber now only propagates that typed failure
and still captures every other error.

The IStaffRecipientsReader binding moves from container.ts to
composition/sources/notifications.ts, where the host binds the ports a
module declares.
@axelhamil
axelhamil merged commit f29bd3e into develop Nov 10, 2026
5 checks passed
@axelhamil
axelhamil deleted the refactor/173-module-schemas-notification-staff branch November 10, 2026 09:31
@axelhamil-bot axelhamil-bot Bot mentioned this pull request Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Tooling, CI, docs or refactor with no user-facing change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module migration step 5c: notification and staff tables into their modules

1 participant