# Async standup app database schema

Source: https://personalsoftwarefactory.com/schemas/async-standups
Updated: 2026-12-04

> Twelve tables. check_ins carries the design: one row per member, standup and report date, with the prompt, due and close instants computed once in the member's schedule zone and stored in UTC, so a clock change never moves an old deadline. answers copy the question text so questions stay editable, and blockers live in their own table with a partial unique index that allows one open blocker per person per standup.

- 12 tables, 9 indexes
- Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite 0.6.1) on 2026-12-04
- 303 seed rows from the blueprint
- The blueprint's test build passed 32 of 32 acceptance checks

Files: [async-standups.sql](https://personalsoftwarefactory.com/schemas/async-standups.sql) · [async-standups-seed.sql](https://personalsoftwarefactory.com/schemas/async-standups-seed.sql) · [the Async Standups blueprint](https://personalsoftwarefactory.com/blueprints/async-standups)

## Relationships

- standups.created_by references people.id: each standups row points to exactly one people row, and one people row can have many standups rows pointing to it.
- standup_days.standup_id references standups.id: each standup_days row points to exactly one standups row, and one standups row can have many standup_days rows pointing to it.
- questions.standup_id references standups.id: each questions row points to exactly one standups row, and one standups row can have many questions rows pointing to it.
- question_options.question_id references questions.id: each question_options row points to exactly one questions row, and one questions row can have many question_options rows pointing to it.
- members.standup_id references standups.id: each members row points to exactly one standups row, and one standups row can have many members rows pointing to it.
- members.person_id references people.id: each members row points to exactly one people row, and one people row can have many members rows pointing to it.
- check_ins.standup_id references standups.id: each check_ins row points to exactly one standups row, and one standups row can have many check_ins rows pointing to it.
- check_ins.person_id references people.id: each check_ins row points to exactly one people row, and one people row can have many check_ins rows pointing to it.
- check_ins.nudged_by references people.id: each check_ins row points to at most one people row, and one people row can have many check_ins rows pointing to it.
- answers.check_in_id references check_ins.id: each answers row points to exactly one check_ins row, and one check_ins row can have many answers rows pointing to it.
- answers.question_id references questions.id: each answers row points to exactly one questions row, and one questions row can have many answers rows pointing to it.
- blockers.standup_id references standups.id: each blockers row points to exactly one standups row, and one standups row can have many blockers rows pointing to it.
- blockers.person_id references people.id: each blockers row points to exactly one people row, and one people row can have many blockers rows pointing to it.
- blockers.opened_check_in_id references check_ins.id: each blockers row points to exactly one check_ins row, and one check_ins row can have many blockers rows pointing to it.
- blockers.resolved_by references people.id: each blockers row points to at most one people row, and one people row can have many blockers rows pointing to it.
- blockers.resolved_check_in_id references check_ins.id: each blockers row points to at most one check_ins row, and one check_ins row can have many blockers rows pointing to it.
- out_of_office.person_id references people.id: each out_of_office row points to exactly one people row, and one people row can have many out_of_office rows pointing to it.
- notifications.standup_id references standups.id: each notifications row points to exactly one standups row, and one standups row can have many notifications rows pointing to it.
- notifications.person_id references people.id: each notifications row points to at most one people row, and one people row can have many notifications rows pointing to it.
- notifications.check_in_id references check_ins.id: each notifications row points to at most one check_ins row, and one check_ins row can have many notifications rows pointing to it. On delete: set null.
- summary_runs.standup_id references standups.id: each summary_runs row points to exactly one standups row, and one standups row can have many summary_runs rows pointing to it.

## Tables

Also described as: daily standup tool database design, standup bot database tables, team check-in app schema.

### people

A person on the team, with their time zone and admin flag. Implements: Person.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  | Check: `LENGTH(name) BETWEEN 1 AND 80` |
| `email` | TEXT | no |  | Unique | stored lowercase Check: `email = LOWER(email)` |
| `time_zone` | TEXT | no | `'America/New_York'` |  | IANA name; the schedule zone for local-timing standups |
| `is_admin` | BOOLEAN | no | `FALSE` |  |  |
| `active` | BOOLEAN | no | `TRUE` |  |  |
| `created_at` | TIMESTAMP | no |  |  |  |

- App rule (R13): there is always at least one active admin.

### standups

One standup with its schedule, reminder, summary time and Slack webhook. Implements: Standup.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  | Check: `LENGTH(name) BETWEEN 1 AND 60` |
| `status` | TEXT | no | `'active'` |  | Check: `status IN ('active', 'paused')` |
| `paused_at` | TIMESTAMP | yes |  |  |  |
| `visibility` | TEXT | no |  |  | Check: `visibility IN ('team', 'members')` |
| `timing` | TEXT | no |  |  | local: each member's own zone; fixed: time_zone below Check: `timing IN ('local', 'fixed')` |
| `time_zone` | TEXT | no |  |  | IANA name; the zone for fixed timing and for the summary |
| `prompt_time` | TEXT | no |  |  | HH:MM, 24-hour Check: `prompt_time LIKE '__:__' AND prompt_time BETWEEN '04:00' AND '22:00'` |
| `due_time` | TEXT | no |  |  | HH:MM, 24-hour Check: `due_time LIKE '__:__' AND due_time BETWEEN '04:00' AND '22:00'` |
| `reminder_minutes` | INTEGER | yes |  |  | empty means no reminder Check: `reminder_minutes BETWEEN 15 AND 480` |
| `summary_time` | TEXT | yes |  |  | HH:MM in time_zone, any time of day; empty means no summary Check: `summary_time LIKE '__:__'` |
| `slack_webhook_url` | TEXT | yes |  |  | secret: never shown in full after saving, never exported or logged |
| `created_by` | TEXT | no |  | References people.id |  |
| `created_at` | TIMESTAMP | no |  |  |  |

- Table check: `due_time > prompt_time`
- Table check: `(status = 'paused' AND paused_at IS NOT NULL) OR (status = 'active' AND paused_at IS NULL)`
- Unique index `standups_name_uniq` on (LOWER(name))
- App rule (R3): prompt_time plus reminder_minutes must be earlier than due_time.

### standup_days

One ISO weekday a standup runs on. Implements: child table of Standup.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `standup_id` | TEXT | no |  | Primary key (part); References standups.id |  |
| `weekday` | INTEGER | no |  | Primary key (part) | ISO weekday: 1 = Monday, 7 = Sunday Check: `weekday BETWEEN 1 AND 7` |

- App rule (R3): every standup has at least one day.

### questions

One question on a standup's form, in position order. Implements: Question.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `standup_id` | TEXT | no |  | References standups.id |  |
| `position` | INTEGER | no |  |  | order on the form |
| `text` | TEXT | no |  |  | Check: `LENGTH(text) BETWEEN 1 AND 200` |
| `kind` | TEXT | no |  |  | Check: `kind IN ('text', 'choice', 'blocker')` |
| `required` | BOOLEAN | no |  |  |  |
| `archived_at` | TIMESTAMP | yes |  |  | archived questions leave new forms; their answers stay |

- Table check: `kind <> 'blocker' OR required = TRUE`
- Index `questions_standup_idx` on (standup_id, position)
- Unique index `questions_one_blocker` on (standup_id) where `kind = 'blocker' AND archived_at IS NULL`
- App rule (R3): 1 to 8 active questions per standup; a question with answers can't change its kind; archiving is final.

### question_options

One option of a choice question, in button order. Implements: child table of Question.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `question_id` | TEXT | no |  | Primary key (part); References questions.id |  |
| `position` | INTEGER | no |  | Primary key (part) | button order |
| `label` | TEXT | no |  |  | stored trimmed Check: `LENGTH(label) BETWEEN 1 AND 40` |

- Unique index `question_options_label_uniq` on (question_id, LOWER(label))
- App rule (R3): choice questions have 2 to 6 options; only choice questions have options.

### members

A person's place in a standup, with the reports, manager and email summary flags. Implements: Member.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `standup_id` | TEXT | no |  | References standups.id |  |
| `person_id` | TEXT | no |  | References people.id |  |
| `reports` | BOOLEAN | no |  |  | gets check-ins |
| `is_manager` | BOOLEAN | no |  |  |  |
| `email_summary` | BOOLEAN | no |  |  |  |
| `joined_at` | TIMESTAMP | no |  |  | set when added or re-added; never changed by flag edits |
| `removed_at` | TIMESTAMP | yes |  |  |  |

- Unique together: `standup_id`, `person_id`
- App rule (R4): removing a member, or unticking reports, deletes their open check-ins that have no submission.

### check_ins

One member's check-in for one standup and report date, with its stored instants and status. Implements: CheckIn.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `standup_id` | TEXT | no |  | References standups.id |  |
| `person_id` | TEXT | no |  | References people.id |  |
| `report_date` | DATE | no |  |  | calendar date in schedule_zone |
| `schedule_zone` | TEXT | no |  |  | IANA zone used, copied at creation |
| `prompt_at` | TIMESTAMP | no |  |  | report_date at prompt_time in schedule_zone |
| `due_at` | TIMESTAMP | no |  |  | report_date at due_time in schedule_zone |
| `closes_at` | TIMESTAMP | no |  |  | the next day at 00:00 in schedule_zone |
| `status` | TEXT | no |  |  | Check: `status IN ('open', 'on_time', 'late', 'missed', 'away')` |
| `prompted_at` | TIMESTAMP | yes |  |  | when the prompt was queued; empty when created as away |
| `reminded_at` | TIMESTAMP | yes |  |  |  |
| `nudged_at` | TIMESTAMP | yes |  |  | R14: once per check-in |
| `nudged_by` | TEXT | yes |  | References people.id |  |
| `submitted_at` | TIMESTAMP | yes |  |  | first submission; decides on_time (at or before due_at) or late (R7) |
| `edited_at` | TIMESTAMP | yes |  |  | last edit |
| `created_at` | TIMESTAMP | no |  |  |  |

- Unique together: `standup_id`, `person_id`, `report_date`
- Table check: `prompt_at < due_at AND due_at < closes_at`
- Table check: `(status IN ('on_time', 'late') AND submitted_at IS NOT NULL) OR (status NOT IN ('on_time', 'late') AND submitted_at IS NULL)`
- Table check: `edited_at IS NULL OR submitted_at IS NOT NULL`
- Table check: `(nudged_at IS NULL AND nudged_by IS NULL) OR (nudged_at IS NOT NULL AND nudged_by IS NOT NULL)`
- Index `check_ins_report_date_idx` on (standup_id, report_date)
- Index `check_ins_open_idx` on (closes_at) where `status = 'open'`
- App rule (section 6): prompt_at, due_at and closes_at are computed once with the time zone database for the report date, never by adding fixed offsets.
- App rule (section 7): missed and away are final; on_time and late can be edited until closes_at.

### answers

One answer to one question in a check-in, with a copy of the question text. Implements: Answer.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `check_in_id` | TEXT | no |  | References check_ins.id |  |
| `question_id` | TEXT | no |  | References questions.id |  |
| `question_text` | TEXT | no |  |  | copied when saved |
| `kind` | TEXT | no |  |  | copied when saved Check: `kind IN ('text', 'choice', 'blocker')` |
| `text` | TEXT | yes |  |  | for a blocker question, the answer text from section 8 ("Blocked: ...") Check: `LENGTH(text) <= 2000` |
| `choice` | TEXT | yes |  |  |  |
| `blocker_action` | TEXT | yes |  |  | blocker questions only Check: `blocker_action IN ('none', 'blocked', 'still_blocked', 'unblocked', 'blocked_other')` |
| `blocker_text` | TEXT | yes |  |  | the new blocker's description Check: `LENGTH(blocker_text) BETWEEN 1 AND 500` |

- Unique together: `check_in_id`, `question_id`
- Table check: `kind = 'choice' OR choice IS NULL`
- Table check: `kind <> 'choice' OR text IS NULL`
- Table check: `kind = 'blocker' OR blocker_action IS NULL`
- Table check: `CASE WHEN blocker_action IN ('blocked', 'blocked_other') THEN blocker_text IS NOT NULL ELSE blocker_text IS NULL END`

### blockers

One blocker a person reported in a standup, open until resolved. Implements: Blocker.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `standup_id` | TEXT | no |  | References standups.id |  |
| `person_id` | TEXT | no |  | References people.id |  |
| `text` | TEXT | no |  |  | Check: `LENGTH(text) BETWEEN 1 AND 500` |
| `opened_check_in_id` | TEXT | no |  | References check_ins.id |  |
| `opened_on` | DATE | no |  |  | report date |
| `opened_at` | TIMESTAMP | no |  |  | submitted_at of the opening check-in |
| `last_reported_on` | DATE | no |  |  | report date of the latest "Still blocked" |
| `status` | TEXT | no |  |  | Check: `status IN ('open', 'resolved')` |
| `resolved_at` | TIMESTAMP | yes |  |  |  |
| `resolved_by` | TEXT | yes |  | References people.id |  |
| `resolved_check_in_id` | TEXT | yes |  | References check_ins.id | set when resolved from a report |
| `resolution_note` | TEXT | yes |  |  | optional Check: `LENGTH(resolution_note) <= 300` |

- Table check: `(status = 'open' AND resolved_at IS NULL AND resolved_by IS NULL AND resolved_check_in_id IS NULL AND resolution_note IS NULL) OR (status = 'resolved' AND resolved_at IS NOT NULL AND resolved_by IS NOT NULL)`
- Table check: `last_reported_on >= opened_on`
- Unique index `blockers_one_open` on (standup_id, person_id) where `status = 'open'`
- App rule (R11): resolved by the person, a current manager of the standup or an admin; a resolved blocker is never reopened.

### out_of_office

One out-of-office period of a person, inclusive report dates. Implements: OutOfOffice.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `person_id` | TEXT | no |  | References people.id |  |
| `start_date` | DATE | no |  |  | inclusive report date |
| `end_date` | DATE | no |  |  | inclusive report date |
| `note` | TEXT | yes |  |  | optional Check: `LENGTH(note) <= 100` |
| `created_at` | TIMESTAMP | no |  |  |  |

- Table check: `end_date >= start_date`
- Index `out_of_office_person_idx` on (person_id, start_date)
- App rule (R12): at most 90 days counting both ends; periods of one person never overlap; the start is not before today.

### notifications

One outgoing email or Slack post in the outbox. Implements: Notification.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `channel` | TEXT | no |  |  | Check: `channel IN ('email', 'slack')` |
| `kind` | TEXT | no |  |  | Check: `kind IN ('prompt', 'reminder', 'nudge', 'report_post', 'blocker_opened', 'blocker_resolved', 'summary')` |
| `standup_id` | TEXT | no |  | References standups.id |  |
| `person_id` | TEXT | yes |  | References people.id | empty for Slack |
| `to_address` | TEXT | no |  |  | the spec's "to": an email address, or "Slack: <standup name>" |
| `check_in_id` | TEXT | yes |  | References check_ins.id, on delete set null | cleared when R4 deletes the check-in; the row stays |
| `subject` | TEXT | no |  |  |  |
| `body` | TEXT | no |  |  | plain text, unescaped |
| `status` | TEXT | no | `'queued'` |  | logged = no email provider; not an attempt Check: `status IN ('queued', 'sent', 'logged', 'failed')` |
| `attempts` | INTEGER | no | `0` |  | each send attempt adds 1; retried until 5 Check: `attempts BETWEEN 0 AND 5` |
| `last_error` | TEXT | yes |  |  | "HTTP 404: no_team" or the error message, never the webhook URL |
| `created_at` | TIMESTAMP | no |  |  |  |
| `sent_at` | TIMESTAMP | yes |  |  |  |

- Index `notifications_status_idx` on (status, attempts)

### summary_runs

One daily summary already sent for a standup and report date. Implements: SummaryRun.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `standup_id` | TEXT | no |  | References standups.id |  |
| `report_date` | DATE | no |  |  | in the standup's time_zone |
| `created_at` | TIMESTAMP | no |  |  |  |

- Unique together: `standup_id`, `report_date`

## The SQL

```sql
-- Async Standups database schema
-- Source: https://personalsoftwarefactory.com/blueprints/async-standups (data model, section 5 of the blueprint)
-- Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite). All timestamps are UTC.
-- License: MIT. Free to copy and adapt.

-- A person on the team. Deactivated, never deleted.
-- App rule (R13): there is always at least one active admin.
CREATE TABLE people (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 1 AND 80),
  email TEXT NOT NULL UNIQUE CHECK (email = LOWER(email)), -- stored lowercase
  time_zone TEXT NOT NULL DEFAULT 'America/New_York', -- IANA name; the schedule zone for local-timing standups
  is_admin BOOLEAN NOT NULL DEFAULT FALSE,
  active BOOLEAN NOT NULL DEFAULT TRUE,
  created_at TIMESTAMP NOT NULL
);

-- One standup: its schedule, reminder, summary and Slack settings.
-- App rule (R3): prompt_time plus reminder_minutes must be earlier than due_time.
CREATE TABLE standups (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 1 AND 60),
  status TEXT NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'paused')),
  paused_at TIMESTAMP,
  visibility TEXT NOT NULL CHECK (visibility IN ('team', 'members')),
  timing TEXT NOT NULL CHECK (timing IN ('local', 'fixed')), -- local: each member's own zone; fixed: time_zone below
  time_zone TEXT NOT NULL, -- IANA name; the zone for fixed timing and for the summary
  prompt_time TEXT NOT NULL CHECK (prompt_time LIKE '__:__' AND prompt_time BETWEEN '04:00' AND '22:00'), -- HH:MM, 24-hour
  due_time TEXT NOT NULL CHECK (due_time LIKE '__:__' AND due_time BETWEEN '04:00' AND '22:00'), -- HH:MM, 24-hour
  reminder_minutes INTEGER CHECK (reminder_minutes BETWEEN 15 AND 480), -- empty means no reminder
  summary_time TEXT CHECK (summary_time LIKE '__:__'), -- HH:MM in time_zone, any time of day; empty means no summary
  slack_webhook_url TEXT, -- secret: never shown in full after saving, never exported or logged
  created_by TEXT NOT NULL REFERENCES people(id),
  created_at TIMESTAMP NOT NULL,
  CHECK (due_time > prompt_time),
  CHECK ((status = 'paused' AND paused_at IS NOT NULL) OR (status = 'active' AND paused_at IS NULL))
);
CREATE UNIQUE INDEX standups_name_uniq ON standups (LOWER(name)); -- unique ignoring case

-- One weekday a standup runs on (child table of Standup.days).
-- App rule (R3): every standup has at least one day.
CREATE TABLE standup_days (
  standup_id TEXT NOT NULL REFERENCES standups(id),
  weekday INTEGER NOT NULL CHECK (weekday BETWEEN 1 AND 7), -- ISO weekday: 1 = Monday, 7 = Sunday
  PRIMARY KEY (standup_id, weekday)
);

-- One question on a standup's form.
-- App rule (R3): 1 to 8 active questions per standup; a question with answers can't change its kind; archiving is final.
CREATE TABLE questions (
  id TEXT PRIMARY KEY,
  standup_id TEXT NOT NULL REFERENCES standups(id),
  position INTEGER NOT NULL, -- order on the form
  text TEXT NOT NULL CHECK (LENGTH(text) BETWEEN 1 AND 200),
  kind TEXT NOT NULL CHECK (kind IN ('text', 'choice', 'blocker')),
  required BOOLEAN NOT NULL,
  archived_at TIMESTAMP, -- archived questions leave new forms; their answers stay
  CHECK (kind <> 'blocker' OR required = TRUE) -- a blocker question is always required
);
CREATE INDEX questions_standup_idx ON questions (standup_id, position);
CREATE UNIQUE INDEX questions_one_blocker ON questions (standup_id) WHERE kind = 'blocker' AND archived_at IS NULL; -- R3: at most one active blocker question

-- One option of a choice question (child table of Question.options).
-- App rule (R3): choice questions have 2 to 6 options; only choice questions have options.
CREATE TABLE question_options (
  question_id TEXT NOT NULL REFERENCES questions(id),
  position INTEGER NOT NULL, -- button order
  label TEXT NOT NULL CHECK (LENGTH(label) BETWEEN 1 AND 40), -- stored trimmed
  PRIMARY KEY (question_id, position)
);
CREATE UNIQUE INDEX question_options_label_uniq ON question_options (question_id, LOWER(label)); -- options differ ignoring case

-- A person's place in a standup, with their flags.
-- App rule (R4): removing a member, or unticking reports, deletes their open check-ins that have no submission.
CREATE TABLE members (
  id TEXT PRIMARY KEY,
  standup_id TEXT NOT NULL REFERENCES standups(id),
  person_id TEXT NOT NULL REFERENCES people(id),
  reports BOOLEAN NOT NULL, -- gets check-ins
  is_manager BOOLEAN NOT NULL,
  email_summary BOOLEAN NOT NULL,
  joined_at TIMESTAMP NOT NULL, -- set when added or re-added; never changed by flag edits
  removed_at TIMESTAMP,
  UNIQUE (standup_id, person_id)
);

-- One member's check-in for one standup and one report date. Created only by the scheduled job.
-- App rule (section 6): prompt_at, due_at and closes_at are computed once with the time zone database for the report date, never by adding fixed offsets.
-- App rule (section 7): missed and away are final; on_time and late can be edited until closes_at.
CREATE TABLE check_ins (
  id TEXT PRIMARY KEY,
  standup_id TEXT NOT NULL REFERENCES standups(id),
  person_id TEXT NOT NULL REFERENCES people(id),
  report_date DATE NOT NULL, -- calendar date in schedule_zone
  schedule_zone TEXT NOT NULL, -- IANA zone used, copied at creation
  prompt_at TIMESTAMP NOT NULL, -- report_date at prompt_time in schedule_zone
  due_at TIMESTAMP NOT NULL, -- report_date at due_time in schedule_zone
  closes_at TIMESTAMP NOT NULL, -- the next day at 00:00 in schedule_zone
  status TEXT NOT NULL CHECK (status IN ('open', 'on_time', 'late', 'missed', 'away')),
  prompted_at TIMESTAMP, -- when the prompt was queued; empty when created as away
  reminded_at TIMESTAMP,
  nudged_at TIMESTAMP, -- R14: once per check-in
  nudged_by TEXT REFERENCES people(id),
  submitted_at TIMESTAMP, -- first submission; decides on_time (at or before due_at) or late (R7)
  edited_at TIMESTAMP, -- last edit
  created_at TIMESTAMP NOT NULL,
  UNIQUE (standup_id, person_id, report_date),
  CHECK (prompt_at < due_at AND due_at < closes_at),
  CHECK ((status IN ('on_time', 'late') AND submitted_at IS NOT NULL) OR (status NOT IN ('on_time', 'late') AND submitted_at IS NULL)),
  CHECK (edited_at IS NULL OR submitted_at IS NOT NULL),
  CHECK ((nudged_at IS NULL AND nudged_by IS NULL) OR (nudged_at IS NOT NULL AND nudged_by IS NOT NULL))
);
CREATE INDEX check_ins_report_date_idx ON check_ins (standup_id, report_date);
CREATE INDEX check_ins_open_idx ON check_ins (closes_at) WHERE status = 'open';

-- One answer to one question in a check-in. Keeps its own copy of the question text.
CREATE TABLE answers (
  id TEXT PRIMARY KEY,
  check_in_id TEXT NOT NULL REFERENCES check_ins(id),
  question_id TEXT NOT NULL REFERENCES questions(id),
  question_text TEXT NOT NULL, -- copied when saved
  kind TEXT NOT NULL CHECK (kind IN ('text', 'choice', 'blocker')), -- copied when saved
  text TEXT CHECK (LENGTH(text) <= 2000), -- for a blocker question, the answer text from section 8 ("Blocked: ...")
  choice TEXT,
  blocker_action TEXT CHECK (blocker_action IN ('none', 'blocked', 'still_blocked', 'unblocked', 'blocked_other')), -- blocker questions only
  blocker_text TEXT CHECK (LENGTH(blocker_text) BETWEEN 1 AND 500), -- the new blocker's description
  UNIQUE (check_in_id, question_id),
  CHECK (kind = 'choice' OR choice IS NULL),
  CHECK (kind <> 'choice' OR text IS NULL),
  CHECK (kind = 'blocker' OR blocker_action IS NULL),
  CHECK (CASE WHEN blocker_action IN ('blocked', 'blocked_other') THEN blocker_text IS NOT NULL ELSE blocker_text IS NULL END) -- R8: a new blocker needs a description
);

-- One blocker a person reported in a standup, open until someone resolves it.
-- App rule (R11): resolved by the person, a current manager of the standup or an admin; a resolved blocker is never reopened.
CREATE TABLE blockers (
  id TEXT PRIMARY KEY,
  standup_id TEXT NOT NULL REFERENCES standups(id),
  person_id TEXT NOT NULL REFERENCES people(id),
  text TEXT NOT NULL CHECK (LENGTH(text) BETWEEN 1 AND 500),
  opened_check_in_id TEXT NOT NULL REFERENCES check_ins(id),
  opened_on DATE NOT NULL, -- report date
  opened_at TIMESTAMP NOT NULL, -- submitted_at of the opening check-in
  last_reported_on DATE NOT NULL, -- report date of the latest "Still blocked"
  status TEXT NOT NULL CHECK (status IN ('open', 'resolved')),
  resolved_at TIMESTAMP,
  resolved_by TEXT REFERENCES people(id),
  resolved_check_in_id TEXT REFERENCES check_ins(id), -- set when resolved from a report
  resolution_note TEXT CHECK (LENGTH(resolution_note) <= 300), -- optional
  CHECK ((status = 'open' AND resolved_at IS NULL AND resolved_by IS NULL AND resolved_check_in_id IS NULL AND resolution_note IS NULL) OR (status = 'resolved' AND resolved_at IS NOT NULL AND resolved_by IS NOT NULL)),
  CHECK (last_reported_on >= opened_on)
);
CREATE UNIQUE INDEX blockers_one_open ON blockers (standup_id, person_id) WHERE status = 'open'; -- R10: one open blocker per person per standup

-- One out-of-office period of a person; applies to every standup they report in.
-- App rule (R12): at most 90 days counting both ends; periods of one person never overlap; the start is not before today.
CREATE TABLE out_of_office (
  id TEXT PRIMARY KEY,
  person_id TEXT NOT NULL REFERENCES people(id),
  start_date DATE NOT NULL, -- inclusive report date
  end_date DATE NOT NULL, -- inclusive report date
  note TEXT CHECK (LENGTH(note) <= 100), -- optional
  created_at TIMESTAMP NOT NULL,
  CHECK (end_date >= start_date)
);
CREATE INDEX out_of_office_person_idx ON out_of_office (person_id, start_date);

-- One outgoing email or Slack post in the outbox.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  channel TEXT NOT NULL CHECK (channel IN ('email', 'slack')),
  kind TEXT NOT NULL CHECK (kind IN ('prompt', 'reminder', 'nudge', 'report_post', 'blocker_opened', 'blocker_resolved', 'summary')),
  standup_id TEXT NOT NULL REFERENCES standups(id),
  person_id TEXT REFERENCES people(id), -- empty for Slack
  to_address TEXT NOT NULL, -- the spec's "to": an email address, or "Slack: <standup name>"
  check_in_id TEXT REFERENCES check_ins(id) ON DELETE SET NULL, -- cleared when R4 deletes the check-in; the row stays
  subject TEXT NOT NULL,
  body TEXT NOT NULL, -- plain text, unescaped
  status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued', 'sent', 'logged', 'failed')), -- logged = no email provider; not an attempt
  attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts BETWEEN 0 AND 5), -- each send attempt adds 1; retried until 5
  last_error TEXT, -- "HTTP 404: no_team" or the error message, never the webhook URL
  created_at TIMESTAMP NOT NULL,
  sent_at TIMESTAMP
);
CREATE INDEX notifications_status_idx ON notifications (status, attempts);

-- One daily summary already sent for a standup and report date; makes the job safe to repeat.
CREATE TABLE summary_runs (
  id TEXT PRIMARY KEY,
  standup_id TEXT NOT NULL REFERENCES standups(id),
  report_date DATE NOT NULL, -- in the standup's time_zone
  created_at TIMESTAMP NOT NULL,
  UNIQUE (standup_id, report_date)
);
```

## Seed data

Loads all of section 15: 9 people, 2 standups with their 6 weekday rows, 7 questions with 6 choice options, 11 members, Tom Bennett's out-of-office period, 61 check-ins (the Product daily grid, the two Leadership weekly Mondays and today's 6), 195 answers and 5 blockers. Check-in instants were computed from each schedule zone with the time zone database. Reports the spec does not list use its default answers, including the unlisted questions of the listed reports. The outbox and summary runs are empty, as the spec says.

## Load it

```sh
# SQLite
curl -s https://personalsoftwarefactory.com/schemas/async-standups.sql https://personalsoftwarefactory.com/schemas/async-standups-seed.sql | sqlite3 async_standups.db
# PostgreSQL
createdb async_standups && curl -s https://personalsoftwarefactory.com/schemas/async-standups.sql https://personalsoftwarefactory.com/schemas/async-standups-seed.sql | psql -v ON_ERROR_STOP=1 async_standups
```

## Design decisions

### Check-in instants are stored, not recalculated

Section 6 computes prompt_at, due_at and closes_at once, with the time zone database for the report date, and never recalculates them. Storing them in UTC on check_ins lets the job, the feed and Insights compare against now with plain SQL. Code that stores one offset per person gets the week of Mon 26 Oct 2026 wrong, when London is four hours ahead of New York instead of five.

### Unique keys make the job safe to repeat

Section 13 says running the job twice creates nothing new because of the unique keys on CheckIn and SummaryRun. check_ins is UNIQUE on (standup_id, person_id, report_date) and summary_runs on (standup_id, report_date), so a second run, or two at once, fails the insert instead of sending a second prompt or summary.

### One open blocker is a partial unique index

R10 allows at most one open blocker per person per standup, enforced with a unique key. A plain UNIQUE would also forbid a second resolved blocker, so the index covers only rows WHERE status = 'open'. The build test found a gap here: R10 covered a blocker resolved after the form loaded but not one opened meanwhile; the index is what makes the second case fail safely. (This point comes from a gap the blueprint's build test found.)

### Answers copy the question text and kind

Section 5 lets a question's text, required flag and options change after it has answers, because each answer keeps its own copy. answers.question_text and answers.kind are copied on save, so the feed, the export and the Last time line show what the person was actually asked. A blocker answer stores its section 8 text ("Blocked: ...") in text and the action in blocker_action. The build test found the seed didn't say what text a blocker answer stores; it is now the section 8 text. (This point comes from a gap the blueprint's build test found.)

### Days and options are child tables

Standup.days and Question.options are lists in the spec. standup_days stores one ISO weekday per row with a 1 to 7 CHECK, and question_options one label per row with a unique index on LOWER(label), which enforces R3's "different options, compared ignoring case" in the database. The counts (at least one day, 2 to 6 options) are cross-row rules and stay in the app. The build test found "different" options didn't say whether Good and good differ; they are compared trimmed and ignoring case. (This point comes from a gap the blueprint's build test found.)

### Outbox rows outlive deleted check-ins

R4 deletes a removed member's open, unsubmitted check-ins, and section 5 says the notification row stays with check_in_id cleared. ON DELETE SET NULL on notifications.check_in_id does exactly that. The build test found that nothing said what happened to those outbox rows; this is the fix. (This point comes from a gap the blueprint's build test found.)

### The spec's "to" column is to_address

Notification has a field named to, which is a reserved word in PostgreSQL and would need quoting everywhere. It is stored as to_address with the same meaning: an email address, or "Slack: <standup name>" for a Slack post.

## Example queries

### Day status for the feed and the summary

```sql
SELECT p.name, CASE WHEN c.status IN ('on_time', 'late') THEN 'reported' WHEN c.status = 'away' THEN 'away' WHEN c.status = 'missed' OR (c.status = 'open' AND c.closes_at <= '2026-10-14 14:00:00') THEN 'missed' ELSE 'waiting' END AS day_status, c.submitted_at FROM members m JOIN people p ON p.id = m.person_id LEFT JOIN check_ins c ON c.standup_id = m.standup_id AND c.person_id = m.person_id AND c.report_date = '2026-10-14' WHERE m.standup_id = 'standup_product_daily' AND m.reports = TRUE AND m.removed_at IS NULL ORDER BY CASE WHEN c.status IN ('on_time', 'late') THEN 0 WHEN c.status = 'away' THEN 3 WHEN c.status = 'missed' OR (c.status = 'open' AND c.closes_at <= '2026-10-14 14:00:00') THEN 2 ELSE 1 END, c.submitted_at, p.name;
```

On the seed data at Wed 14 Oct 2026 14:00 UTC: 7 rows, Priya Nair, Maya Chen and Sam Okafor reported, Ben Cho, Jo Park and Lee Park waiting, Tom Bennett away (3 of 6 reported). Lee has no check-in yet; the app decides waiting from his schedule.

### Participation per person (Insights)

```sql
SELECT name, on_time, late, missed, away, reported, counted, CASE WHEN counted = 0 THEN NULL ELSE (200 * reported + counted) / (2 * counted) END AS rate_percent FROM (SELECT p.name, SUM(CASE WHEN c.status = 'on_time' THEN 1 ELSE 0 END) AS on_time, SUM(CASE WHEN c.status = 'late' THEN 1 ELSE 0 END) AS late, SUM(CASE WHEN c.status = 'missed' OR (c.status = 'open' AND c.closes_at <= '2026-10-14 14:00:00') THEN 1 ELSE 0 END) AS missed, SUM(CASE WHEN c.status = 'away' THEN 1 ELSE 0 END) AS away, SUM(CASE WHEN c.status IN ('on_time', 'late') THEN 1 ELSE 0 END) AS reported, SUM(CASE WHEN c.status IN ('on_time', 'late', 'missed') OR (c.status = 'open' AND c.closes_at <= '2026-10-14 14:00:00') THEN 1 ELSE 0 END) AS counted FROM check_ins c JOIN people p ON p.id = c.person_id WHERE c.standup_id = 'standup_product_daily' AND c.report_date BETWEEN '2026-09-30' AND '2026-10-13' GROUP BY p.name) per_person ORDER BY name;
```

On the seed data for Wed 30 Sep to Tue 13 Oct: 7 rows, matching section 10's worked example, for example Jo Park 3 on time, 1 late, 3 missed, 4 of 7, 57%.

### Team participation row

```sql
SELECT SUM(CASE WHEN status IN ('on_time', 'late') THEN 1 ELSE 0 END) AS reported, SUM(CASE WHEN status IN ('on_time', 'late', 'missed') OR (status = 'open' AND closes_at <= '2026-10-14 14:00:00') THEN 1 ELSE 0 END) AS counted, (200 * SUM(CASE WHEN status IN ('on_time', 'late') THEN 1 ELSE 0 END) + SUM(CASE WHEN status IN ('on_time', 'late', 'missed') OR (status = 'open' AND closes_at <= '2026-10-14 14:00:00') THEN 1 ELSE 0 END)) / (2 * SUM(CASE WHEN status IN ('on_time', 'late', 'missed') OR (status = 'open' AND closes_at <= '2026-10-14 14:00:00') THEN 1 ELSE 0 END)) AS rate_percent FROM check_ins WHERE standup_id = 'standup_product_daily' AND report_date BETWEEN '2026-10-05' AND '2026-10-14';
```

On the seed data for Mon 5 to Wed 14 Oct: 1 row, 45 of 50 (90%), as in section 10; Jo's and Ben's open check-ins are not counted yet.

### Open blockers, oldest first

```sql
SELECT p.name, s.name AS standup, b.text, b.opened_on, b.last_reported_on FROM blockers b JOIN people p ON p.id = b.person_id JOIN standups s ON s.id = b.standup_id WHERE b.status = 'open' ORDER BY b.opened_on, b.opened_at, p.name;
```

On the seed data: 3 rows, Dana Ruiz (Leadership weekly, since 2026-10-12), Jo Park (Need staging database access from Ana, since 2026-10-13) and Sam Okafor (since 2026-10-14).

### The Last time line on Jo's form

```sql
SELECT a.question_text, COALESCE(a.text, a.choice) AS last_answer FROM answers a JOIN questions q ON q.id = a.question_id WHERE a.check_in_id = (SELECT c.id FROM check_ins c WHERE c.standup_id = 'standup_product_daily' AND c.person_id = 'person_jo' AND c.status IN ('on_time', 'late') AND c.report_date < '2026-10-14' ORDER BY c.report_date DESC LIMIT 1) ORDER BY q.position;
```

On the seed data: 4 rows from Jo's Tue 13 Oct report, for example "Fixed the login crash on Android 15" and "Blocked: Need staging database access from Ana".

## What was not tested

- MySQL, MariaDB, SQL Server and Oracle. The file avoids engine-specific syntax, but it was not run on them.
- Other versions of SQLite and PostgreSQL than the two named above.
- PostgreSQL as a server. The PostgreSQL run used PGlite, which is PostgreSQL compiled to run in-process.
- Production load. The check loads the seed rows and runs the example queries; it says nothing about performance with real volumes.
- Migrations. This is a schema for a new database, not a path from an existing one.

## The blueprint

This schema is section 5 of the [Async Standups blueprint](https://personalsoftwarefactory.com/blueprints/async-standups), which also has the business rules, the screens, the phased build prompts and the acceptance checks. Paste-ready spec: https://personalsoftwarefactory.com/blueprints/async-standups/blueprint.md
