Bug tracking system database schema
Ten tables. The bugs table carries the design: one row per bug with a severity, a priority set at triage, a status from a fixed list of nine, a fix-due time and a pointer to the bug it duplicates, with table checks that keep the reporter, closed time, fix fields and duplicate pointer consistent with the status. An append-only events table is the activity log and the source of the weekly summary counts.
- 10 tables, 5 indexes
- Verified on SQLite 3.53.4 and PostgreSQL 19.0 (PGlite 0.6.1),
- 102 seed rows from the blueprint
- The blueprint's test build passed 31 of 31 acceptance checks
Bug tracker entity-relationship diagram
Relationships
- bugs.area_id references areas.id: each bugs row points to at most one areas row, and one areas row can have many bugs rows pointing to it.
- bugs.reporter_id references people.id: each bugs row points to at most one people row, and one people row can have many bugs rows pointing to it.
- bugs.assignee_id references people.id: each bugs row points to at most one people row, and one people row can have many bugs rows pointing to it.
- bugs.duplicate_of_id references bugs.id: each bugs row points to at most one another bugs row, and one bugs row can have many bugs rows pointing to it.
- bugs.fixed_by_id references people.id: each bugs row points to at most one people row, and one people row can have many bugs rows pointing to it.
- watchers.bug_id references bugs.id: each watchers row points to exactly one bugs row, and one bugs row can have many watchers rows pointing to it.
- watchers.person_id references people.id: each watchers row points to exactly one people row, and one people row can have many watchers rows pointing to it.
- comments.bug_id references bugs.id: each comments row points to exactly one bugs row, and one bugs row can have many comments rows pointing to it.
- comments.author_id references people.id: each comments row points to exactly one people row, and one people row can have many comments rows pointing to it.
- events.bug_id references bugs.id: each events row points to exactly one bugs row, and one bugs row can have many events rows pointing to it.
- events.actor_id references people.id: each events row points to at most one people row, and one people row can have many events 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.bug_id references bugs.id: each notifications row points to at most one bugs row, and one bugs row can have many notifications rows pointing to it.
Bug tracker tables
The schema has 10 tables. Every column below is read from the SQL file itself. Also described as: issue tracker database design, bug tracker database tables, defect tracking data model.
| Table | Implements | What a row is |
|---|---|---|
settings | Settings | The single row with the company name, time zone, fix targets per severity, reopen window, form switch and the bug number counter. |
people | Person | Someone who can sign in, with admin, triager and QA flags. |
areas | Area | A part of the product, such as Web app or Payments. |
bugs | Bug | One reported bug with its status, severity, priority, reporter, assignee, fix and due times. |
watchers | Watcher | A person who gets notifications about one bug. |
comments | Comment | A comment on a bug; never edited or deleted. |
events | Event | One line of a bug's append-only activity log. |
notifications | Notification | One email in the outbox, with its send status and attempts. |
summary_runs | SummaryRun | A week whose summary has been queued, so it is sent once. |
form_attempts | FormAttempt | One accepted public-form report, keyed by a hash of the IP, for the rate limit. |
settings
The single settings row for the team.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | INTEGER | no | Primary key | one row onlyCheck: id = 1 | |
company_name | TEXT | no | Check: LENGTH(company_name) BETWEEN 1 AND 60 | ||
time_zone | TEXT | no | 'America/New_York' | IANA name; days, weeks and shown times use it | |
target_s1_hours | INTEGER | yes | 24 | NULL means no fix targetCheck: target_s1_hours BETWEEN 1 AND 8760 | |
target_s2_hours | INTEGER | yes | 168 | Check: target_s2_hours BETWEEN 1 AND 8760 | |
target_s3_hours | INTEGER | yes | 720 | Check: target_s3_hours BETWEEN 1 AND 8760 | |
target_s4_hours | INTEGER | yes | empty by defaultCheck: target_s4_hours BETWEEN 1 AND 8760 | ||
reopen_window_days | INTEGER | no | 30 | Check: reopen_window_days BETWEEN 1 AND 365 | |
form_enabled | BOOLEAN | no | TRUE | the public report form is on | |
last_bug_number | INTEGER | no | 100 | R2: a new bug takes last_bug_number + 1 in the same transaction |
people
Someone who can sign in. People are deactivated, never deleted.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
name | TEXT | no | Check: LENGTH(name) BETWEEN 1 AND 100 | ||
email | TEXT | no | Unique | stored lowercaseCheck: email = LOWER(email) | |
is_admin | BOOLEAN | no | FALSE | ||
is_triager | BOOLEAN | no | FALSE | ||
is_qa | BOOLEAN | no | FALSE | ||
active | BOOLEAN | no | TRUE |
- App rule (R16): there is always at least one active admin and one active triager; a person assigned to open bugs cannot be deactivated.
areas
A part of the product a bug belongs to. Inactive areas stay on existing bugs.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
name | TEXT | no | Check: LENGTH(name) BETWEEN 2 AND 40 | ||
active | BOOLEAN | no | TRUE |
- Unique index
areas_name_uniqon(LOWER(name))
bugs
One reported bug, from a team member or the public form.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
number | INTEGER | no | Unique | shown as BUG-104; never reused (R2) | |
version | INTEGER | no | 1 | Check: version >= 1 | |
title | TEXT | no | Check: LENGTH(title) BETWEEN 5 AND 120 | ||
area_id | TEXT | yes | References areas.id | may be empty until triage | |
severity | TEXT | no | Check: severity IN ('s1', 's2', 's3', 's4') | ||
priority | TEXT | yes | empty until triageCheck: priority IN ('p1', 'p2', 'p3', 'p4') | ||
status | TEXT | no | 'new' | Check: status IN ('new', 'triaged', 'in_progress', 'in_review', 'fixed', 'verified', 'wont_fix', 'cannot_reproduce', 'duplicate') | |
steps | TEXT | no | Check: LENGTH(steps) BETWEEN 10 AND 5000 | ||
expected | TEXT | yes | optionalCheck: LENGTH(expected) <= 2000 | ||
actual | TEXT | no | what happenedCheck: LENGTH(actual) BETWEEN 1 AND 2000 | ||
environment | TEXT | yes | where it happened; required on team reports (see the table check)Check: LENGTH(environment) <= 200 | ||
link | TEXT | yes | optional screenshot, recording or pageCheck: LENGTH(link) <= 2000 AND link LIKE 'https://%' | ||
source | TEXT | no | Check: source IN ('team', 'form') | ||
reporter_id | TEXT | yes | References people.id | team reports only | |
reporter_name | TEXT | yes | form reports onlyCheck: LENGTH(reporter_name) BETWEEN 1 AND 100 | ||
reporter_email | TEXT | yes | form reports only, stored lowercaseCheck: LENGTH(reporter_email) <= 254 AND reporter_email = LOWER(reporter_email) | ||
assignee_id | TEXT | yes | References people.id | at most one assignee | |
duplicate_of_id | TEXT | yes | References bugs.id | set exactly while status is duplicate | |
review_link | TEXT | yes | optional, from Send to reviewCheck: review_link LIKE 'https://%' | ||
fix_note | TEXT | yes | set by Mark fixed, cleared by ReopenCheck: LENGTH(fix_note) BETWEEN 10 AND 2000 | ||
fixed_by_id | TEXT | yes | References people.id | the latest fix | |
fixed_at | TIMESTAMP | yes | |||
fix_due_at | TIMESTAMP | yes | NULL when the severity has no target | ||
overdue_notified_at | TIMESTAMP | yes | one overdue notice per due time | ||
triaged_at | TIMESTAMP | yes | |||
closed_at | TIMESTAMP | yes | set exactly while the bug is closed | ||
reopen_count | INTEGER | no | 0 | Check: reopen_count >= 0 | |
created_at | TIMESTAMP | no | |||
updated_at | TIMESTAMP | no | time of its latest event |
- Table check:
(source = 'team' AND reporter_id IS NOT NULL AND reporter_name IS NULL AND reporter_email IS NULL) OR (source = 'form' AND reporter_id IS NULL AND reporter_name IS NOT NULL AND reporter_email IS NOT NULL) - Table check:
source = 'form' OR (environment IS NOT NULL AND LENGTH(environment) >= 2) - Table check:
(status = 'duplicate' AND duplicate_of_id IS NOT NULL) OR (status <> 'duplicate' AND duplicate_of_id IS NULL) - Table check:
duplicate_of_id IS NULL OR duplicate_of_id <> id - Table check:
(status IN ('verified', 'wont_fix', 'cannot_reproduce', 'duplicate') AND closed_at IS NOT NULL) OR (status IN ('new', 'triaged', 'in_progress', 'in_review', 'fixed') AND closed_at IS NULL) - Table check:
status NOT IN ('triaged', 'in_progress', 'in_review', 'fixed', 'verified') OR (priority IS NOT NULL AND area_id IS NOT NULL) - Table check:
status NOT IN ('in_progress', 'in_review', 'fixed') OR assignee_id IS NOT NULL - Table check:
status NOT IN ('fixed', 'verified') OR (fix_note IS NOT NULL AND fixed_by_id IS NOT NULL AND fixed_at IS NOT NULL) - Index
bugs_status_idxon(status) - Index
bugs_duplicate_of_idxon(duplicate_of_id) - App rule (R1, section 6): who may move a bug from which status to which is checked by the app.
- App rule (section 7): fix_due_at = created_at + the target hours for the severity; recalculated on a severity change, which also clears overdue_notified_at.
- App rule (section 8): duplicate_of_id always points at a bug that is not itself a duplicate.
- App rule (R17): version goes up by 1 on every action on this bug except Comment, Watch and Unwatch.
watchers
A person who gets notifications about a bug.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
bug_id | TEXT | no | Primary key (part); References bugs.id | ||
person_id | TEXT | no | Primary key (part); References people.id |
comments
A comment on a bug. Comments cannot be edited or deleted in v1.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
bug_id | TEXT | no | References bugs.id | ||
author_id | TEXT | no | References people.id | ||
body | TEXT | no | Check: LENGTH(body) BETWEEN 1 AND 5000 | ||
created_at | TIMESTAMP | no |
events
One line of the activity log of a bug. Append-only.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
seq | INTEGER | no | Unique | increasing; orders events written at the same moment | |
bug_id | TEXT | no | References bugs.id | ||
actor_id | TEXT | yes | References people.id | NULL for the system and for form reports | |
type | TEXT | no | Check: type IN ('reported', 'edited', 'triaged', 'severity_changed', 'priority_changed', 'assigned', 'unassigned', 'started', 'sent_to_review', 'review_returned', 'fixed', 'verified', 'reopened', 'wont_fix', 'cannot_reproduce', 'marked_duplicate', 'duplicate_added', 'unmarked_duplicate', 'commented', 'overdue') | ||
data | TEXT | yes | JSON text: from/to values, changed field names, comment_id, fix note, bug numbers | ||
created_at | TIMESTAMP | no |
- Index
events_bug_idxon(bug_id, created_at, seq) - App rule (R15): events are never edited or deleted.
notifications
One email in the outbox, written in the same transaction as the action.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | ||
kind | TEXT | no | Check: kind IN ('new_bug', 'acknowledgement', 'assigned', 'ready_to_verify', 'verified', 'fixed_for_reporter', 'reopened', 'closed', 'duplicate', 'comment', 'overdue', 'weekly_summary') | ||
person_id | TEXT | yes | References people.id | NULL for outside reporters | |
to_email | TEXT | no | |||
bug_id | TEXT | yes | References bugs.id | NULL for weekly summaries | |
subject | TEXT | no | |||
body | TEXT | no | |||
status | TEXT | no | 'queued' | Check: status IN ('queued', 'sent', 'logged', 'failed') | |
attempts | INTEGER | no | 0 | the job retries until 5 attemptsCheck: attempts >= 0 | |
error | TEXT | yes | |||
created_at | TIMESTAMP | no | |||
sent_at | TIMESTAMP | yes |
summary_runs
A weekly summary that has been queued, so a second run that week sends nothing.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
week_start | DATE | no | Primary key | the Monday the summarised week starts on | |
created_at | TIMESTAMP | no |
form_attempts
One accepted public-form report, for the rate limit (R19). The job deletes rows older than 24 hours.
| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
id | TEXT | no | Primary key | row id; the spec lists only ip_hash and created_at | |
ip_hash | TEXT | no | HMAC-SHA256 of the IP address with FORM_IP_SECRET; the IP itself is never stored | ||
created_at | TIMESTAMP | no |
- Index
form_attempts_ip_idxon(ip_hash, created_at)
The SQL
The whole schema in one file. It runs top to bottom, unmodified, on SQLite and PostgreSQL. Download bug-tracker.sql or copy it from here.
-- Bug Tracker database schema
-- Source: https://personalsoftwarefactory.com/blueprints/bug-tracker (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 for the team.
CREATE TABLE settings (
id INTEGER PRIMARY KEY CHECK (id = 1), -- one row only
company_name TEXT NOT NULL CHECK (LENGTH(company_name) BETWEEN 1 AND 60),
time_zone TEXT NOT NULL DEFAULT 'America/New_York', -- IANA name; days, weeks and shown times use it
target_s1_hours INTEGER DEFAULT 24 CHECK (target_s1_hours BETWEEN 1 AND 8760), -- NULL means no fix target
target_s2_hours INTEGER DEFAULT 168 CHECK (target_s2_hours BETWEEN 1 AND 8760),
target_s3_hours INTEGER DEFAULT 720 CHECK (target_s3_hours BETWEEN 1 AND 8760),
target_s4_hours INTEGER CHECK (target_s4_hours BETWEEN 1 AND 8760), -- empty by default
reopen_window_days INTEGER NOT NULL DEFAULT 30 CHECK (reopen_window_days BETWEEN 1 AND 365),
form_enabled BOOLEAN NOT NULL DEFAULT TRUE, -- the public report form is on
last_bug_number INTEGER NOT NULL DEFAULT 100 -- R2: a new bug takes last_bug_number + 1 in the same transaction
);
-- Someone who can sign in. People are deactivated, never deleted.
-- App rule (R16): there is always at least one active admin and one active triager; a person assigned to open bugs cannot be deactivated.
CREATE TABLE people (
id TEXT PRIMARY KEY,
name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 1 AND 100),
email TEXT NOT NULL UNIQUE CHECK (email = LOWER(email)), -- stored lowercase
is_admin BOOLEAN NOT NULL DEFAULT FALSE,
is_triager BOOLEAN NOT NULL DEFAULT FALSE,
is_qa BOOLEAN NOT NULL DEFAULT FALSE,
active BOOLEAN NOT NULL DEFAULT TRUE
);
-- A part of the product a bug belongs to. Inactive areas stay on existing bugs.
CREATE TABLE areas (
id TEXT PRIMARY KEY,
name TEXT NOT NULL CHECK (LENGTH(name) BETWEEN 2 AND 40),
active BOOLEAN NOT NULL DEFAULT TRUE
);
CREATE UNIQUE INDEX areas_name_uniq ON areas (LOWER(name)); -- unique ignoring case
-- One reported bug, from a team member or the public form.
-- App rule (R1, section 6): who may move a bug from which status to which is checked by the app.
-- App rule (section 7): fix_due_at = created_at + the target hours for the severity; recalculated on a severity change, which also clears overdue_notified_at.
-- App rule (section 8): duplicate_of_id always points at a bug that is not itself a duplicate.
-- App rule (R17): version goes up by 1 on every action on this bug except Comment, Watch and Unwatch.
CREATE TABLE bugs (
id TEXT PRIMARY KEY,
number INTEGER NOT NULL UNIQUE, -- shown as BUG-104; never reused (R2)
version INTEGER NOT NULL DEFAULT 1 CHECK (version >= 1),
title TEXT NOT NULL CHECK (LENGTH(title) BETWEEN 5 AND 120),
area_id TEXT REFERENCES areas(id), -- may be empty until triage
severity TEXT NOT NULL CHECK (severity IN ('s1', 's2', 's3', 's4')),
priority TEXT CHECK (priority IN ('p1', 'p2', 'p3', 'p4')), -- empty until triage
status TEXT NOT NULL DEFAULT 'new' CHECK (status IN ('new', 'triaged', 'in_progress', 'in_review', 'fixed', 'verified', 'wont_fix', 'cannot_reproduce', 'duplicate')),
steps TEXT NOT NULL CHECK (LENGTH(steps) BETWEEN 10 AND 5000),
expected TEXT CHECK (LENGTH(expected) <= 2000), -- optional
actual TEXT NOT NULL CHECK (LENGTH(actual) BETWEEN 1 AND 2000), -- what happened
environment TEXT CHECK (LENGTH(environment) <= 200), -- where it happened; required on team reports (see the table check)
link TEXT CHECK (LENGTH(link) <= 2000 AND link LIKE 'https://%'), -- optional screenshot, recording or page
source TEXT NOT NULL CHECK (source IN ('team', 'form')),
reporter_id TEXT REFERENCES people(id), -- team reports only
reporter_name TEXT CHECK (LENGTH(reporter_name) BETWEEN 1 AND 100), -- form reports only
reporter_email TEXT CHECK (LENGTH(reporter_email) <= 254 AND reporter_email = LOWER(reporter_email)), -- form reports only, stored lowercase
assignee_id TEXT REFERENCES people(id), -- at most one assignee
duplicate_of_id TEXT REFERENCES bugs(id), -- set exactly while status is duplicate
review_link TEXT CHECK (review_link LIKE 'https://%'), -- optional, from Send to review
fix_note TEXT CHECK (LENGTH(fix_note) BETWEEN 10 AND 2000), -- set by Mark fixed, cleared by Reopen
fixed_by_id TEXT REFERENCES people(id), -- the latest fix
fixed_at TIMESTAMP,
fix_due_at TIMESTAMP, -- NULL when the severity has no target
overdue_notified_at TIMESTAMP, -- one overdue notice per due time
triaged_at TIMESTAMP,
closed_at TIMESTAMP, -- set exactly while the bug is closed
reopen_count INTEGER NOT NULL DEFAULT 0 CHECK (reopen_count >= 0),
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL, -- time of its latest event
CHECK ((source = 'team' AND reporter_id IS NOT NULL AND reporter_name IS NULL AND reporter_email IS NULL)
OR (source = 'form' AND reporter_id IS NULL AND reporter_name IS NOT NULL AND reporter_email IS NOT NULL)),
CHECK (source = 'form' OR (environment IS NOT NULL AND LENGTH(environment) >= 2)), -- R3
CHECK ((status = 'duplicate' AND duplicate_of_id IS NOT NULL) OR (status <> 'duplicate' AND duplicate_of_id IS NULL)),
CHECK (duplicate_of_id IS NULL OR duplicate_of_id <> id),
CHECK ((status IN ('verified', 'wont_fix', 'cannot_reproduce', 'duplicate') AND closed_at IS NOT NULL)
OR (status IN ('new', 'triaged', 'in_progress', 'in_review', 'fixed') AND closed_at IS NULL)),
CHECK (status NOT IN ('triaged', 'in_progress', 'in_review', 'fixed', 'verified') OR (priority IS NOT NULL AND area_id IS NOT NULL)), -- R4
CHECK (status NOT IN ('in_progress', 'in_review', 'fixed') OR assignee_id IS NOT NULL), -- R6: only the assignee does the work
CHECK (status NOT IN ('fixed', 'verified') OR (fix_note IS NOT NULL AND fixed_by_id IS NOT NULL AND fixed_at IS NOT NULL)) -- R7
);
CREATE INDEX bugs_status_idx ON bugs (status);
CREATE INDEX bugs_duplicate_of_idx ON bugs (duplicate_of_id);
-- A person who gets notifications about a bug.
CREATE TABLE watchers (
bug_id TEXT NOT NULL REFERENCES bugs(id),
person_id TEXT NOT NULL REFERENCES people(id),
PRIMARY KEY (bug_id, person_id)
);
-- A comment on a bug. Comments cannot be edited or deleted in v1.
CREATE TABLE comments (
id TEXT PRIMARY KEY,
bug_id TEXT NOT NULL REFERENCES bugs(id),
author_id TEXT NOT NULL REFERENCES people(id),
body TEXT NOT NULL CHECK (LENGTH(body) BETWEEN 1 AND 5000),
created_at TIMESTAMP NOT NULL
);
-- One line of the activity log of a bug. Append-only.
-- App rule (R15): events are never edited or deleted.
CREATE TABLE events (
id TEXT PRIMARY KEY,
seq INTEGER NOT NULL UNIQUE, -- increasing; orders events written at the same moment
bug_id TEXT NOT NULL REFERENCES bugs(id),
actor_id TEXT REFERENCES people(id), -- NULL for the system and for form reports
type TEXT NOT NULL CHECK (type IN ('reported', 'edited', 'triaged', 'severity_changed', 'priority_changed', 'assigned', 'unassigned', 'started', 'sent_to_review', 'review_returned', 'fixed', 'verified', 'reopened', 'wont_fix', 'cannot_reproduce', 'marked_duplicate', 'duplicate_added', 'unmarked_duplicate', 'commented', 'overdue')),
data TEXT, -- JSON text: from/to values, changed field names, comment_id, fix note, bug numbers
created_at TIMESTAMP NOT NULL
);
CREATE INDEX events_bug_idx ON events (bug_id, created_at, seq);
-- One email in the outbox, written in the same transaction as the action.
CREATE TABLE notifications (
id TEXT PRIMARY KEY,
kind TEXT NOT NULL CHECK (kind IN ('new_bug', 'acknowledgement', 'assigned', 'ready_to_verify', 'verified', 'fixed_for_reporter', 'reopened', 'closed', 'duplicate', 'comment', 'overdue', 'weekly_summary')),
person_id TEXT REFERENCES people(id), -- NULL for outside reporters
to_email TEXT NOT NULL,
bug_id TEXT REFERENCES bugs(id), -- NULL for weekly summaries
subject TEXT NOT NULL,
body TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued', 'sent', 'logged', 'failed')),
attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0), -- the job retries until 5 attempts
error TEXT,
created_at TIMESTAMP NOT NULL,
sent_at TIMESTAMP
);
-- A weekly summary that has been queued, so a second run that week sends nothing.
CREATE TABLE summary_runs (
week_start DATE PRIMARY KEY, -- the Monday the summarised week starts on
created_at TIMESTAMP NOT NULL
);
-- One accepted public-form report, for the rate limit (R19). The job deletes rows older than 24 hours.
CREATE TABLE form_attempts (
id TEXT PRIMARY KEY, -- row id; the spec lists only ip_hash and created_at
ip_hash TEXT NOT NULL, -- HMAC-SHA256 of the IP address with FORM_IP_SECRET; the IP itself is never stored
created_at TIMESTAMP NOT NULL
);
CREATE INDEX form_attempts_ip_idx ON form_attempts (ip_hash, created_at);Seed data
Loads everything section 14 seeds: the settings row, 8 people, 4 areas, the 14 bugs (9 open, 5 closed), 23 watchers, the 4 comments and the 48 events their histories imply, with team times (EDT) converted to UTC. Placeholders: the spec leaves the steps, what happened and where it happened text of seeded bugs to the builder, so steps, actual and environment hold one fixed placeholder each, the same on every row (environment stays empty on Erin Walsh's form report, where it is optional); expected is optional and left empty. Event data is left empty because the spec names what it carries but not its JSON shape. No notifications, summary runs or form attempts are seeded, as the spec says.
Download bug-tracker-seed.sql (102 rows). It loads with foreign keys enforced on both engines.
Load it
SQLite, into a new file:
curl -s https://personalsoftwarefactory.com/schemas/bug-tracker.sql https://personalsoftwarefactory.com/schemas/bug-tracker-seed.sql | sqlite3 bug_tracker.dbPostgreSQL, into a new database:
createdb bug_tracker && curl -s https://personalsoftwarefactory.com/schemas/bug-tracker.sql https://personalsoftwarefactory.com/schemas/bug-tracker-seed.sql | psql -v ON_ERROR_STOP=1 bug_trackerSQLite only enforces foreign keys when the connection asks for it: run PRAGMA foreign_keys = ON; when your app opens the database.
Design decisions
Bug numbers come from a counter on the settings row
R2 says a new bug takes Settings.last_bug_number + 1 and stores it back in the same transaction, so numbers are sequential and never reused. bugs.number is UNIQUE, which also stops two concurrent reports from getting the same number. MAX(number) + 1 would hand out a number twice under load.
The status decides which other columns must be set
Section 5 says closed_at is set exactly while a bug is closed, R4 requires a priority and an area before triage, R6 lets only the assignee do the work and R7 makes Mark fixed set fixed_by, fixed_at and the fix note. Each of these is a table CHECK on bugs written so a NULL cannot slip through. The transitions themselves (who may move a bug from which status) stay in the app.
Team and form reporters share one table, with a check
Section 5 gives team reports a reporter_id and form reports a name and email instead. A CHECK makes those two shapes the only ones allowed, and another makes where it happened required, with at least 2 characters, on team reports only, as R3 and R19 say. Outside reporters are not people rows, because they never sign in.
Duplicates point at one canonical bug
duplicate_of_id references bugs and is set exactly while the status is duplicate. Section 8 moves every duplicate of D to C when D itself becomes a duplicate, so chains never form and the reports count is 1 plus a single COUNT of rows pointing at the bug. That move is a multi-row update, so it stays an app rule.
Fix targets are nullable hours, due time is stored
Section 7 gives each severity a target of 1 to 8,760 hours or none (S4 has none by default), so the four target columns are nullable with a range CHECK. fix_due_at is stored on the bug, because changing a target in Settings must not move existing due times; a severity change recalculates it from created_at.
A version column for stale screens
R17 sends the version a person saw with every action and saves nothing if it changed. version starts at 1 and the app adds 1 inside the same transaction as the update. Comments, watching and the side effects of Mark duplicate on other bugs leave it alone.
Events are the source of the weekly counts
Section 12 counts Fixed, Verified, Closed without a fix and Reopened from events in the week, not from the current status, because a bug can be fixed, reopened and fixed again in one week. events.seq orders events written at the same moment, and data is JSON stored as TEXT, because JSON types are not portable.
Example queries
The queries behind the tool's main screens. Each returned the same rows on both engines against the seed data.
Board: open bugs by column
SELECT 'BUG-' || b.number AS bug, b.status, UPPER(b.severity) AS sev, COALESCE(UPPER(b.priority), '-') AS pri, COALESCE(p.name, 'Unassigned') AS assignee, 1 + (SELECT COUNT(*) FROM bugs d WHERE d.duplicate_of_id = b.id) AS reports FROM bugs b LEFT JOIN people p ON p.id = b.assignee_id WHERE b.status IN ('new', 'triaged', 'in_progress', 'in_review', 'fixed') ORDER BY CASE b.status WHEN 'new' THEN 1 WHEN 'triaged' THEN 2 WHEN 'in_progress' THEN 3 WHEN 'in_review' THEN 4 ELSE 5 END, CASE WHEN b.priority IS NULL THEN 9 ELSE 0 END, b.priority, b.severity, b.created_at;On the seed data: 9 rows; New has BUG-114 (S1) above BUG-113, and BUG-104 shows 2 reports.
Overdue bugs at the seed time
SELECT 'BUG-' || b.number AS bug, b.title, UPPER(b.severity) AS sev, COALESCE(p.name, 'Unassigned') AS assignee, b.fix_due_at FROM bugs b LEFT JOIN people p ON p.id = b.assignee_id WHERE b.status IN ('new', 'triaged', 'in_progress', 'in_review') AND b.fix_due_at < '2026-10-13 14:00:00' ORDER BY b.fix_due_at;On the seed data at Tue 13 Oct 2026, 10:00 EDT: 2 rows, BUG-102 (due 2026-09-30 14:00 UTC, Kofi Mensah) then BUG-104 (Theo Lindqvist).
Waiting for verification, oldest fix first
SELECT 'BUG-' || b.number AS bug, b.title, f.name AS fixed_by, b.fixed_at FROM bugs b JOIN people f ON f.id = b.fixed_by_id WHERE b.status = 'fixed' ORDER BY b.fixed_at;On the seed data: 3 rows, BUG-107 (Theo Lindqvist), BUG-106 (Kofi Mensah), BUG-108 (Grace Kim).
Weekly summary counts for Mon 5 to Sun 11 Oct
SELECT (SELECT COUNT(*) FROM bugs WHERE created_at >= '2026-10-05 04:00:00' AND created_at < '2026-10-12 04:00:00') AS reported, (SELECT COUNT(DISTINCT bug_id) FROM events WHERE type = 'fixed' AND created_at >= '2026-10-05 04:00:00' AND created_at < '2026-10-12 04:00:00') AS fixed, (SELECT COUNT(DISTINCT bug_id) FROM events WHERE type = 'verified' AND created_at >= '2026-10-05 04:00:00' AND created_at < '2026-10-12 04:00:00') AS verified, (SELECT COUNT(DISTINCT bug_id) FROM events WHERE type IN ('wont_fix', 'cannot_reproduce', 'marked_duplicate') AND created_at >= '2026-10-05 04:00:00' AND created_at < '2026-10-12 04:00:00') AS closed_without_fix, (SELECT COUNT(DISTINCT bug_id) FROM events WHERE type = 'reopened' AND created_at >= '2026-10-05 04:00:00' AND created_at < '2026-10-12 04:00:00') AS reopened;On the seed data: 1 row, Reported 6, Fixed 2, Verified 1, Closed without a fix 3, Reopened 1, matching the summary example in section 12.
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 Bug Tracker blueprint, a free spec that also has the business rules, the screens, 4 phased build prompts and 31 acceptance checks for building the whole tool with an AI app builder. We built it from those prompts and the result passed 31 of 31 acceptance checks in a browser.
- Read the Bug Tracker blueprint: rules, screens, build prompts and acceptance checks
- Read the build-test field report: what the test build got wrong and what was not tested
- All database schemas
- How we test blueprints
Follow new blueprints
Every new blueprint and build test appears in the feed and in the public GitHub repository. No account, no email list.