Lets digest-service.ts know when each user's next digest is due. digest_schedule holds, for each user and cadence they receive, the start of the period their next digest covers; it is due once a full period has passed.

Functions

f
up(db: DatabaseSync): void

Run once by runMigrations. Every user present gets both cadences, with a first period that ends at some hour of the coming week or month, picked from their id: the digests start trickling out after the deploy instead of all leaving a week later. Users created later are scheduled by the service when it first sees them.

Usage

import * as mod from "api/db/migrations/0020_digest_schedule.ts";