Files
mangaBookmark/backend/internal/store/migrations/0014_admin_read_model.sql
T
sulthan e0b9063d9e feat(store): cross-series admin read model with privacy in the projection (#140)
SeriesPage returns one 50-row page of Series matching one of eight named hygiene filters (all, no_series_url, never_read_a_chapter, no_readers, never_checked, stale, no_cover, reader_report), with a window-count total; SeriesShapes returns the per-Site aggregate, one grouped pass. The compound filter value object takes Site, Kind, Name, a caller-supplied staleness cutoff, and a 1-based page.

The privacy boundary lives in the projection: adminSeriesColumns never selects latest_raised_by, and AdminSeries has no field for it — a SQL-computed boolean is all that crosses. LEFT JOIN surfaces orphans (reader_count 0); (site, series_id) tie-breaks the zero-stamp boundary so pages stay stable.

Also lands 0014: the series(latest_checked_at) index and series.force_poll_at, both expand-step schema for later tickets in the series.
2026-08-21 18:20:59 +07:00

12 lines
677 B
SQL

-- Admin read-model foundation (#140). The Series list's default order is
-- least-recently-checked first, so the table — which has only its primary key
-- today — gets an index that can serve it. A grouped query over a join may
-- ignore the index, so this is a judgement, not a measurement: re-time on real
-- data before adding a second.
CREATE INDEX series_latest_checked_at_idx ON series (latest_checked_at);
-- force_poll_at is the "ask for one Series to be checked now" stamp (#146).
-- Zero means never forced; nothing reads the column before that ticket wires
-- it, so it lands here unused.
ALTER TABLE series ADD COLUMN force_poll_at bigint NOT NULL DEFAULT 0;