Status page database schema

Sixteen tables. The design rests on status_changes, an append-only log of every component status change that uptime and the 90-day bars are computed from, and on incident_updates with a child table of the component statuses each update set, which decides who gets emailed. A component's current status is stored for the page, but R6 defines it as the worst status still set by open incidents and running maintenance. Subscribers follow either all components or a list of them.

  • 16 tables, 2 indexes
  • Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite 0.6.1),
  • 49 seed rows from the blueprint
  • The blueprint's test build passed 18 of 18 acceptance checks

Copy the SQLDownload SQLDownload seed data

By Sam Claassen · From the Status Page blueprint · MIT licensed · Markdown version

Status page entity-relationship diagram

settingsidPK+ 8 more columnsteam_membersidPK+ 4 more columnscomponent_groupsidPK+ 2 more columnstemplatesidPK+ 3 more columnscomponentsidPKgroup_id→ component_groupstemplate_id→ templates+ 8 more columnstemplate_componentstemplate_idPK → templatescomponent_idPK → components+ 1 more columnincidentsidPKcreated_by→ team_membersrelated_to→ incidents+ 8 more columnsincident_updatesidPKincident_id→ incidentsauthor_id→ team_members+ 4 more columnsincident_update_componentsupdate_idPK → incident_updatescomponent_idPK → components+ 1 more columnmaintenance_windowsidPK+ 7 more columnsmaintenance_componentsmaintenance_idPK → maintenance…component_idPK → componentsstatus_changesidPKcomponent_id→ componentsincident_id→ incidentsmaintenance_id→ maintenance_wi…+ 3 more columnssubscribersidPK+ 8 more columnssubscriber_componentssubscriber_idPK → subscriberscomponent_idPK → componentseventsidPK+ 4 more columnsnotificationsidPKincident_id→ incidentsmaintenance_id→ maintenance_wi…+ 9 more columnssettingsidPK+ 8 more columnsteam_membersidPK+ 4 more columnscomponent_groupsidPK+ 2 more columnstemplatesidPK+ 3 more columnscomponentsidPKgroup_id→ component_groupstemplate_id→ templates+ 8 more columnstemplate_componentstemplate_idPK → templatescomponent_idPK → components+ 1 more columnincidentsidPKcreated_by→ team_membersrelated_to→ incidents+ 8 more columnsincident_updatesidPKincident_id→ incidentsauthor_id→ team_members+ 4 more columnsincident_update_componentsupdate_idPK → incident_updatescomponent_idPK → components+ 1 more columnmaintenance_windowsidPK+ 7 more columnsmaintenance_componentsmaintenance_idPK → maintenance…component_idPK → componentsstatus_changesidPKcomponent_id→ componentsincident_id→ incidentsmaintenance_id→ maintenance_wi…+ 3 more columnssubscribersidPK+ 8 more columnssubscriber_componentssubscriber_idPK → subscriberscomponent_idPK → componentseventsidPK+ 4 more columnsnotificationsidPKincident_id→ incidentsmaintenance_id→ maintenance_wi…+ 9 more columns
Each box is a table with its key columns. A line runs from a table up to a table it references, with the forked end on the side that has many rows; a dashed line is an optional reference.

Relationships

  • components.group_id references component_groups.id: each components row points to at most one component_groups row, and one component_groups row can have many components rows pointing to it.
  • components.template_id references templates.id: each components row points to at most one templates row, and one templates row can have many components rows pointing to it.
  • template_components.template_id references templates.id: each template_components row points to exactly one templates row, and one templates row can have many template_components rows pointing to it. On delete: cascade.
  • template_components.component_id references components.id: each template_components row points to exactly one components row, and one components row can have many template_components rows pointing to it.
  • incidents.created_by references team_members.id: each incidents row points to at most one team_members row, and one team_members row can have many incidents rows pointing to it.
  • incidents.related_to references incidents.id: each incidents row points to at most one another incidents row, and one incidents row can have many incidents rows pointing to it.
  • incident_updates.incident_id references incidents.id: each incident_updates row points to exactly one incidents row, and one incidents row can have many incident_updates rows pointing to it. On delete: cascade.
  • incident_updates.author_id references team_members.id: each incident_updates row points to at most one team_members row, and one team_members row can have many incident_updates rows pointing to it.
  • incident_update_components.update_id references incident_updates.id: each incident_update_components row points to exactly one incident_updates row, and one incident_updates row can have many incident_update_components rows pointing to it. On delete: cascade.
  • incident_update_components.component_id references components.id: each incident_update_components row points to exactly one components row, and one components row can have many incident_update_components rows pointing to it.
  • maintenance_components.maintenance_id references maintenance_windows.id: each maintenance_components row points to exactly one maintenance_windows row, and one maintenance_windows row can have many maintenance_components rows pointing to it. On delete: cascade.
  • maintenance_components.component_id references components.id: each maintenance_components row points to exactly one components row, and one components row can have many maintenance_components rows pointing to it.
  • status_changes.component_id references components.id: each status_changes row points to exactly one components row, and one components row can have many status_changes rows pointing to it.
  • status_changes.incident_id references incidents.id: each status_changes row points to at most one incidents row, and one incidents row can have many status_changes rows pointing to it.
  • status_changes.maintenance_id references maintenance_windows.id: each status_changes row points to at most one maintenance_windows row, and one maintenance_windows row can have many status_changes rows pointing to it.
  • subscriber_components.subscriber_id references subscribers.id: each subscriber_components row points to exactly one subscribers row, and one subscribers row can have many subscriber_components rows pointing to it. On delete: cascade.
  • subscriber_components.component_id references components.id: each subscriber_components row points to exactly one components row, and one components row can have many subscriber_components rows pointing to it.
  • notifications.incident_id references incidents.id: each notifications row points to at most one incidents row, and one incidents row can have many notifications rows pointing to it.
  • notifications.maintenance_id references maintenance_windows.id: each notifications row points to at most one maintenance_windows row, and one maintenance_windows row can have many notifications rows pointing to it.

Status page tables

The schema has 16 tables. Every column below is read from the SQL file itself. Also described as: incident status page database design, uptime status page data model, Statuspage alternative database tables.

TableImplementsWhat a row is
settingsSettingsThe one row with the page name, company name, time zone, sender, sign-in domain and public address.
team_membersTeamMemberA person on the team who can sign in, as an admin or a responder.
component_groupsComponentGroupA heading on the public page that components are listed under.
templatesTemplateA saved incident title and first message, used by people and by automation.
componentsComponentA part of the product with its current status, automation token and template.
template_componentschild table of TemplateA component a template sets, with the status it sets.
incidentsIncidentAn incident, from draft to resolved, with its impact, times and postmortem.
incident_updatesIncidentUpdateOne timed update on an incident; a draft's text is its unpublished first update.
incident_update_componentschild table of IncidentUpdateA component status set by one update (the update's component_statuses).
maintenance_windowsMaintenanceA scheduled maintenance window with its start, end, status and notify flag.
maintenance_componentschild table of MaintenanceA component a maintenance window puts under maintenance.
status_changesStatusChangeOne change of a component's status, with the incident or maintenance and the actor behind it.
subscribersSubscriberAn email address subscribed to updates, with its confirmation and unsubscribe state.
subscriber_componentschild table of SubscriberA component a subscriber follows when they don't follow all of them.
eventsEventOne entry in the append-only activity log, naming its actor.
notificationsNotificationOne email in the outbox with its subject, headers, attempts and status.

settings

The single settings row. id is fixed at 1 so the table can never hold a second row.

ColumnTypeNullDefaultKeyNotes
idINTEGERnoPrimary keyCheck: id = 1
page_nameTEXTno
company_nameTEXTnoevery public update is signed with it
logoTEXTyesimage URL or file path
time_zoneTEXTno'America/Chicago'IANA name; used for days in uptime bars, emails and admin screens
support_urlTEXTyes
from_emailTEXTyes
email_domainTEXTyesthe only domain team members sign in with
page_urlTEXTyesthe public address used in every email and feed link

team_members

A person on the team who can sign in to /admin.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnonever shown to visitors (R11)
emailTEXTnoUnique
roleTEXTnoCheck: role IN ('admin', 'responder')
activeBOOLEANnoTRUEonly active members can sign in

component_groups

A heading on the public page that components are listed under. Deleted only when empty.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnoUnique
positionINTEGERnodisplay order

templates

A saved starting point for an incident: title, first message and component statuses.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTno
titleTEXTnothe incident title it fills in
messageTEXTnothe message of the first update

components

A part of the product shown on the page with its current status. under_maintenance for each in-progress maintenance affecting it, or operational.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnoUnique
descriptionTEXTyesshown on the public page
group_idTEXTyesReferences component_groups.ida group with components cannot be deleted
positionINTEGERnodisplay order within its group
statusTEXTno'operational'Check: status IN ('operational', 'degraded_performance', 'partial_outage', 'major_outage', 'under_maintenance')
created_atTIMESTAMPnouptime counts from here when it is inside the 90-day window
hiddenBOOLEANnoFALSEhidden components keep their history and do not count toward the banner
automation_tokenTEXTyesUniquesecret for the monitor webhook (R10); generated by the app
auto_publishBOOLEANnoFALSEpublish automation incidents at once instead of leaving a draft
template_idTEXTyesReferences templates.idused by automation; NULL gives the title "Payments: major outage"
  • App rule (R6): status is always the worst of the latest status each open incident set for it and
  • App rule (section 13): a component used by any incident, maintenance or template can only be hidden, not deleted.

template_components

A component a template sets, and the status it sets it to. Only maintenance sets under_maintenance.

ColumnTypeNullDefaultKeyNotes
template_idTEXTnoPrimary key (part); References templates.id, on delete cascade
component_idTEXTnoPrimary key (part); References components.id
statusTEXTnoCheck: status IN ('operational', 'degraded_performance', 'partial_outage', 'major_outage')

incidents

An incident: a draft until published, then open until resolved. Never reopened.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
numberINTEGERnoUniqueshown as INC-0013; given when the draft is createdCheck: number >= 1
titleTEXTno
statusTEXTno'draft'Check: status IN ('draft', 'investigating', 'identified', 'monitoring', 'resolved')
impactTEXTno'minor'Check: impact IN ('none', 'minor', 'major', 'critical')
started_atTIMESTAMPyesset when it is published
resolved_atTIMESTAMPyes
postmortemTEXTyesMarkdown; resolved incidents onlyCheck: length(postmortem) <= 20000
postmortem_atTIMESTAMPyeswhen the postmortem was last added or edited
created_byTEXTyesReferences team_members.idNULL when automation opened it
related_toTEXTyesReferences incidents.idan earlier incident this one follows on from
  • Table check: (status = 'draft' AND started_at IS NULL) OR (status <> 'draft' AND started_at IS NOT NULL)
  • Table check: (status = 'resolved' AND resolved_at IS NOT NULL) OR (status <> 'resolved' AND resolved_at IS NULL)
  • Table check: postmortem IS NULL OR status = 'resolved'
  • App rule (R4): status moves forward only (investigating, identified, monitoring, resolved); steps can be skipped.
  • App rule: only drafts can be deleted, and the number of a deleted draft is not reused.

incident_updates

One update on an incident. The text of a draft is its first update with published_at NULL.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
incident_idTEXTnoReferences incidents.id, on delete cascadecascade only matters for deleted drafts
statusTEXTnoCheck: status IN ('investigating', 'identified', 'monitoring', 'resolved')
messageTEXTnoCheck: length(message) BETWEEN 10 AND 2000
notifyBOOLEANnoemail subscribers of the affected components of the incident (R9)
published_atTIMESTAMPyesNULL only for the text of a draft
author_idTEXTyesReferences team_members.idNULL for automation; never shown publicly
  • App rule (R5): an admin can correct the message after publishing; the original stays in the activity log.

incident_update_components

A component status set by one incident update (the component_statuses list of the update).

ColumnTypeNullDefaultKeyNotes
update_idTEXTnoPrimary key (part); References incident_updates.id, on delete cascade
component_idTEXTnoPrimary key (part); References components.id
statusTEXTnoCheck: status IN ('operational', 'degraded_performance', 'partial_outage', 'major_outage')

maintenance_windows

A scheduled maintenance window (Maintenance in the spec), numbered M-0001.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
numberINTEGERnoUniqueshown as M-0003Check: number >= 1
titleTEXTno
messageTEXTyesoptional
starts_atTIMESTAMPno
ends_atTIMESTAMPno
statusTEXTno'scheduled'Check: status IN ('scheduled', 'in_progress', 'completed', 'cancelled')
notifyBOOLEANno
  • Table check: ends_at > starts_at
  • App rule (R7): the every-minute job starts and completes it on time and sends a reminder 1 hour before.

maintenance_components

A component a maintenance window affects. App rule: at least one per window.

ColumnTypeNullDefaultKeyNotes
maintenance_idTEXTnoPrimary key (part); References maintenance_windows.id, on delete cascade
component_idTEXTnoPrimary key (part); References components.id

status_changes

One change of the status of a component. Append-only; uptime and the 90-day bars come only from this log (R2).

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
component_idTEXTnoReferences components.id
statusTEXTnoCheck: status IN ('operational', 'degraded_performance', 'partial_outage', 'major_outage', 'under_maintenance')
atTIMESTAMPno
incident_idTEXTyesReferences incidents.id
maintenance_idTEXTyesReferences maintenance_windows.id
actorTEXTnoa team member id, 'automation' or 'schedule'
  • Table check: incident_id IS NULL OR maintenance_id IS NULL
  • Index status_changes_component_at on (component_id, at)

subscribers

An email address subscribed to updates. Removing a subscriber deletes the row.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
emailTEXTnoUniquestored lowercaseCheck: email = lower(email)
all_componentsBOOLEANnoFALSETRUE: every component, and subscriber_components is empty
confirm_tokenTEXTyesUniquegenerated by the app
confirm_sent_atTIMESTAMPyes
confirmed_atTIMESTAMPyesonly confirmed subscribers are emailed
manage_tokenTEXTyesUniquefor the manage and one-click unsubscribe links; generated by the app
unsubscribed_atTIMESTAMPyes
created_ipTEXTyes
  • App rule (R8): double opt-in; the confirmation link expires 7 days after confirm_sent_at.

subscriber_components

A component a subscriber follows when all_components is FALSE (component_ids in the spec).

ColumnTypeNullDefaultKeyNotes
subscriber_idTEXTnoPrimary key (part); References subscribers.id, on delete cascade
component_idTEXTnoPrimary key (part); References components.id

events

One entry in the activity log. Append-only (R12).

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
atTIMESTAMPno
actorTEXTnoa team member id, 'schedule', 'automation', 'visitor' or 'outbox'
typeTEXTno
dataTEXTno'{}'a JSON object stored as text

notifications

One email in the outbox, written before it is sent. Subscriber emails keep only the address, so removing a subscriber leaves them.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
kindTEXTno
to_emailTEXTno
subjectTEXTno
bodyTEXTno
headersTEXTyesextra headers such as List-Unsubscribe, as text
created_atTIMESTAMPno
incident_idTEXTyesReferences incidents.id
maintenance_idTEXTyesReferences maintenance_windows.id
attemptsINTEGERno0at most 3 send attempts per emailCheck: attempts BETWEEN 0 AND 3
statusTEXTno'queued'Check: status IN ('queued', 'sent', 'failed', 'logged')
errorTEXTyes
  • Table check: incident_id IS NULL OR maintenance_id IS NULL
  • Index notifications_status on (status)

The SQL

The whole schema in one file. It runs top to bottom, unmodified, on SQLite and PostgreSQL. Download status-page.sql or copy it from here.

status-page.sql
-- Status Page database schema
-- Source: https://personalsoftwarefactory.com/blueprints/status-page (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.

-- The single settings row. id is fixed at 1 so the table can never hold a second row.
CREATE TABLE settings (
  id INTEGER PRIMARY KEY CHECK (id = 1),
  page_name TEXT NOT NULL,
  company_name TEXT NOT NULL, -- every public update is signed with it
  logo TEXT, -- image URL or file path
  time_zone TEXT NOT NULL DEFAULT 'America/Chicago', -- IANA name; used for days in uptime bars, emails and admin screens
  support_url TEXT,
  from_email TEXT,
  email_domain TEXT, -- the only domain team members sign in with
  page_url TEXT -- the public address used in every email and feed link
);

-- A person on the team who can sign in to /admin.
CREATE TABLE team_members (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL, -- never shown to visitors (R11)
  email TEXT NOT NULL UNIQUE,
  role TEXT NOT NULL CHECK (role IN ('admin', 'responder')),
  active BOOLEAN NOT NULL DEFAULT TRUE -- only active members can sign in
);

-- A heading on the public page that components are listed under. Deleted only when empty.
CREATE TABLE component_groups (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL UNIQUE,
  position INTEGER NOT NULL -- display order
);

-- A saved starting point for an incident: title, first message and component statuses.
CREATE TABLE templates (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  title TEXT NOT NULL, -- the incident title it fills in
  message TEXT NOT NULL -- the message of the first update
);

-- A part of the product shown on the page with its current status.
-- App rule (R6): status is always the worst of the latest status each open incident set for it and
-- under_maintenance for each in-progress maintenance affecting it, or operational.
-- App rule (section 13): a component used by any incident, maintenance or template can only be hidden, not deleted.
CREATE TABLE components (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL UNIQUE,
  description TEXT, -- shown on the public page
  group_id TEXT REFERENCES component_groups(id), -- a group with components cannot be deleted
  position INTEGER NOT NULL, -- display order within its group
  status TEXT NOT NULL DEFAULT 'operational' CHECK (status IN ('operational', 'degraded_performance', 'partial_outage', 'major_outage', 'under_maintenance')),
  created_at TIMESTAMP NOT NULL, -- uptime counts from here when it is inside the 90-day window
  hidden BOOLEAN NOT NULL DEFAULT FALSE, -- hidden components keep their history and do not count toward the banner
  automation_token TEXT UNIQUE, -- secret for the monitor webhook (R10); generated by the app
  auto_publish BOOLEAN NOT NULL DEFAULT FALSE, -- publish automation incidents at once instead of leaving a draft
  template_id TEXT REFERENCES templates(id) -- used by automation; NULL gives the title "Payments: major outage"
);

-- A component a template sets, and the status it sets it to. Only maintenance sets under_maintenance.
CREATE TABLE template_components (
  template_id TEXT NOT NULL REFERENCES templates(id) ON DELETE CASCADE,
  component_id TEXT NOT NULL REFERENCES components(id),
  status TEXT NOT NULL CHECK (status IN ('operational', 'degraded_performance', 'partial_outage', 'major_outage')),
  PRIMARY KEY (template_id, component_id)
);

-- An incident: a draft until published, then open until resolved. Never reopened.
-- App rule (R4): status moves forward only (investigating, identified, monitoring, resolved); steps can be skipped.
-- App rule: only drafts can be deleted, and the number of a deleted draft is not reused.
CREATE TABLE incidents (
  id TEXT PRIMARY KEY,
  number INTEGER NOT NULL UNIQUE CHECK (number >= 1), -- shown as INC-0013; given when the draft is created
  title TEXT NOT NULL,
  status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'investigating', 'identified', 'monitoring', 'resolved')),
  impact TEXT NOT NULL DEFAULT 'minor' CHECK (impact IN ('none', 'minor', 'major', 'critical')),
  started_at TIMESTAMP, -- set when it is published
  resolved_at TIMESTAMP,
  postmortem TEXT CHECK (length(postmortem) <= 20000), -- Markdown; resolved incidents only
  postmortem_at TIMESTAMP, -- when the postmortem was last added or edited
  created_by TEXT REFERENCES team_members(id), -- NULL when automation opened it
  related_to TEXT REFERENCES incidents(id), -- an earlier incident this one follows on from
  CHECK ((status = 'draft' AND started_at IS NULL) OR (status <> 'draft' AND started_at IS NOT NULL)),
  CHECK ((status = 'resolved' AND resolved_at IS NOT NULL) OR (status <> 'resolved' AND resolved_at IS NULL)),
  CHECK (postmortem IS NULL OR status = 'resolved')
);

-- One update on an incident. The text of a draft is its first update with published_at NULL.
-- App rule (R5): an admin can correct the message after publishing; the original stays in the activity log.
CREATE TABLE incident_updates (
  id TEXT PRIMARY KEY,
  incident_id TEXT NOT NULL REFERENCES incidents(id) ON DELETE CASCADE, -- cascade only matters for deleted drafts
  status TEXT NOT NULL CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved')),
  message TEXT NOT NULL CHECK (length(message) BETWEEN 10 AND 2000),
  notify BOOLEAN NOT NULL, -- email subscribers of the affected components of the incident (R9)
  published_at TIMESTAMP, -- NULL only for the text of a draft
  author_id TEXT REFERENCES team_members(id) -- NULL for automation; never shown publicly
);

-- A component status set by one incident update (the component_statuses list of the update).
CREATE TABLE incident_update_components (
  update_id TEXT NOT NULL REFERENCES incident_updates(id) ON DELETE CASCADE,
  component_id TEXT NOT NULL REFERENCES components(id),
  status TEXT NOT NULL CHECK (status IN ('operational', 'degraded_performance', 'partial_outage', 'major_outage')),
  PRIMARY KEY (update_id, component_id)
);

-- A scheduled maintenance window (Maintenance in the spec), numbered M-0001.
-- App rule (R7): the every-minute job starts and completes it on time and sends a reminder 1 hour before.
CREATE TABLE maintenance_windows (
  id TEXT PRIMARY KEY,
  number INTEGER NOT NULL UNIQUE CHECK (number >= 1), -- shown as M-0003
  title TEXT NOT NULL,
  message TEXT, -- optional
  starts_at TIMESTAMP NOT NULL,
  ends_at TIMESTAMP NOT NULL,
  status TEXT NOT NULL DEFAULT 'scheduled' CHECK (status IN ('scheduled', 'in_progress', 'completed', 'cancelled')),
  notify BOOLEAN NOT NULL,
  CHECK (ends_at > starts_at)
);

-- A component a maintenance window affects. App rule: at least one per window.
CREATE TABLE maintenance_components (
  maintenance_id TEXT NOT NULL REFERENCES maintenance_windows(id) ON DELETE CASCADE,
  component_id TEXT NOT NULL REFERENCES components(id),
  PRIMARY KEY (maintenance_id, component_id)
);

-- One change of the status of a component. Append-only; uptime and the 90-day bars come only from this log (R2).
CREATE TABLE status_changes (
  id TEXT PRIMARY KEY,
  component_id TEXT NOT NULL REFERENCES components(id),
  status TEXT NOT NULL CHECK (status IN ('operational', 'degraded_performance', 'partial_outage', 'major_outage', 'under_maintenance')),
  at TIMESTAMP NOT NULL,
  incident_id TEXT REFERENCES incidents(id),
  maintenance_id TEXT REFERENCES maintenance_windows(id),
  actor TEXT NOT NULL, -- a team member id, 'automation' or 'schedule'
  CHECK (incident_id IS NULL OR maintenance_id IS NULL)
);
CREATE INDEX status_changes_component_at ON status_changes (component_id, at);

-- An email address subscribed to updates. Removing a subscriber deletes the row.
-- App rule (R8): double opt-in; the confirmation link expires 7 days after confirm_sent_at.
CREATE TABLE subscribers (
  id TEXT PRIMARY KEY,
  email TEXT NOT NULL UNIQUE CHECK (email = lower(email)), -- stored lowercase
  all_components BOOLEAN NOT NULL DEFAULT FALSE, -- TRUE: every component, and subscriber_components is empty
  confirm_token TEXT UNIQUE, -- generated by the app
  confirm_sent_at TIMESTAMP,
  confirmed_at TIMESTAMP, -- only confirmed subscribers are emailed
  manage_token TEXT UNIQUE, -- for the manage and one-click unsubscribe links; generated by the app
  unsubscribed_at TIMESTAMP,
  created_ip TEXT
);

-- A component a subscriber follows when all_components is FALSE (component_ids in the spec).
CREATE TABLE subscriber_components (
  subscriber_id TEXT NOT NULL REFERENCES subscribers(id) ON DELETE CASCADE,
  component_id TEXT NOT NULL REFERENCES components(id),
  PRIMARY KEY (subscriber_id, component_id)
);

-- One entry in the activity log. Append-only (R12).
CREATE TABLE events (
  id TEXT PRIMARY KEY,
  at TIMESTAMP NOT NULL,
  actor TEXT NOT NULL, -- a team member id, 'schedule', 'automation', 'visitor' or 'outbox'
  type TEXT NOT NULL,
  data TEXT NOT NULL DEFAULT '{}' -- a JSON object stored as text
);

-- One email in the outbox, written before it is sent. Subscriber emails keep only the address, so removing a subscriber leaves them.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  kind TEXT NOT NULL,
  to_email TEXT NOT NULL,
  subject TEXT NOT NULL,
  body TEXT NOT NULL,
  headers TEXT, -- extra headers such as List-Unsubscribe, as text
  created_at TIMESTAMP NOT NULL,
  incident_id TEXT REFERENCES incidents(id),
  maintenance_id TEXT REFERENCES maintenance_windows(id),
  attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts BETWEEN 0 AND 3), -- at most 3 send attempts per email
  status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued', 'sent', 'failed', 'logged')),
  error TEXT,
  CHECK (incident_id IS NULL OR maintenance_id IS NULL)
);
CREATE INDEX notifications_status ON notifications (status);

Seed data

Loads section 14: settings, 3 team members, 2 groups, 5 components, 3 templates, INC-0013 and INC-0014 with their 8 updates, M-0003, 9 status changes and 5 subscribers. Left out or filled by stated choice: the 3 logged scheduled-maintenance emails (the spec gives no body, kind or headers); activity log events (none are listed); tokens and page_url (generated or set per install, so NULL); INC-0014's resolved message (none given, so INC-0013's text is reused); notify on the seed updates (not given, set TRUE); component creation (1 Jul 2026, since the spec only says more than 90 days ago); and times of day the spec omits (00:00 CDT).

Download status-page-seed.sql (49 rows). It loads with foreign keys enforced on both engines.

Load it

SQLite, into a new file:

sqlite3
curl -s https://personalsoftwarefactory.com/schemas/status-page.sql https://personalsoftwarefactory.com/schemas/status-page-seed.sql | sqlite3 status_page.db

PostgreSQL, into a new database:

psql
createdb status_page && curl -s https://personalsoftwarefactory.com/schemas/status-page.sql https://personalsoftwarefactory.com/schemas/status-page-seed.sql | psql -v ON_ERROR_STOP=1 status_page

SQLite only enforces foreign keys when the connection asks for it: run PRAGMA foreign_keys = ON; when your app opens the database.

Design decisions

Uptime comes from an append-only status log

From the build test · field report

status_changes gets a row for every status change and rows are never edited (R2), because section 6 computes uptime and each day's bar only from this log. The build test found the spec didn't say what a component's status was before its first row, so every component now gets an operational row when it is created, as the seed does. Uptime itself needs date arithmetic, which differs between engines, so it belongs in the app, not in portable SQL.

An update's component statuses are a child table

From the build test · field report

IncidentUpdate's component_statuses is a list of component and status pairs, stored as incident_update_components. R9 emails subscribers of every component any published update of the incident has set, which the build test found had first been read as only the latest update's components; with a child table that is one join. A CHECK keeps under_maintenance out, since only maintenance sets it (section 7).

A draft's text is its first update

From the build test · field report

There is no draft message column on incidents. The build test found a draft had nowhere to keep its message, and section 5 now says a draft's text is its first IncidentUpdate with published_at NULL. The incident's number is given when the draft is created and started_at is set on publishing, which a CHECK ties to the status.

Subscribers follow all components or a list

all_components is a boolean and subscriber_components holds the list when it is FALSE. R9 sends each update once per subscriber who follows all components or at least one affected component, and unconfirmed or unsubscribed addresses get nothing. Outbox rows keep only to_email with no foreign key, so removing a subscriber (screen 7) deletes the row and leaves emails already written.

Postmortems only on resolved incidents

From the build test · field report

postmortem is Markdown up to 20,000 characters and a CHECK allows it only when the status is resolved, as section 5 says. The build test found postmortems had no rules and no time; postmortem_at now records when it was posted, for the feed.

Current status is stored, but R6 defines it

components.status holds the status the page shows, so the page and the JSON API read it directly. R6 says it is always the worst of the latest status each open incident set for it and under maintenance for each running window, or operational; the app must recompute it on every incident or maintenance change, which no portable constraint can do.

Example queries

The queries behind the tool's main screens. Each returned the same rows on both engines against the seed data.

The banner: overall status of visible components

SQL
SELECT CASE MAX(CASE status
      WHEN 'major_outage' THEN 5 WHEN 'partial_outage' THEN 4 WHEN 'degraded_performance' THEN 3
      WHEN 'under_maintenance' THEN 2 ELSE 1 END)
    WHEN 5 THEN 'Major outage' WHEN 4 THEN 'Partial outage' WHEN 3 THEN 'Degraded performance'
    WHEN 2 THEN 'Under maintenance' ELSE 'All systems operational' END AS banner,
  COUNT(*) AS visible_components
FROM components
WHERE hidden = FALSE;

On the seed data: 1 row; All systems operational, from 5 visible components.

Components by group with their current status

SQL
SELECT g.name AS group_name, c.name AS component, c.status, COALESCE(c.description, '') AS description
FROM components c
JOIN component_groups g ON g.id = c.group_id
WHERE c.hidden = FALSE
ORDER BY g.position, c.position;

On the seed data: 5 rows; Payments in Delivery is operational with the description Processed by Stripe.

Incident history with update counts

SQL
SELECT i.number, i.title, i.impact, i.status,
  (SELECT COUNT(*) FROM incident_updates u WHERE u.incident_id = i.id AND u.published_at IS NOT NULL) AS updates,
  (SELECT u.status FROM incident_updates u WHERE u.incident_id = i.id AND u.published_at IS NOT NULL
   ORDER BY u.published_at DESC LIMIT 1) AS latest_status
FROM incidents i
WHERE i.status <> 'draft'
ORDER BY i.started_at DESC;

On the seed data: 2 rows; INC-0014 (number 14), Invoice emails delayed, resolved after 4 updates, comes first.

Who gets emailed about an incident (R9)

SQL
SELECT s.email
FROM subscribers s
WHERE s.confirmed_at IS NOT NULL
  AND s.unsubscribed_at IS NULL
  AND (s.all_components = TRUE
       OR EXISTS (
         SELECT 1
         FROM subscriber_components sc
         JOIN incident_update_components iuc ON iuc.component_id = sc.component_id
         JOIN incident_updates u ON u.id = iuc.update_id
         WHERE sc.subscriber_id = s.id
           AND u.incident_id = 'inc-0013'
           AND u.published_at IS NOT NULL))
ORDER BY s.email;

On the seed data, for INC-0013: 3 rows; ana@studio.example, lee@agency.example and sam@clientco.example.

Upcoming maintenance and its components

SQL
SELECT m.number, m.title, m.status, c.name AS component
FROM maintenance_windows m
JOIN maintenance_components mc ON mc.maintenance_id = m.id
JOIN components c ON c.id = mc.component_id
WHERE m.status IN ('scheduled', 'in_progress')
ORDER BY m.starts_at, c.position;

On the seed data: 2 rows; M-0003 (number 3), Database upgrade, scheduled for Dashboard and API.

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 comes from

Tables are the easy half. This schema is section 5 of the Status Page blueprint, a free spec that also has the business rules, the screens, 4 phased build prompts and 18 acceptance checks for building the whole tool with an AI app builder. We built it from those prompts and the result passed 18 of 18 acceptance checks in a browser.

Follow new blueprints

Every new blueprint and build test appears in the feed and in the public GitHub repository. No account, no email list.