Feature request tracking system database schema

Fifteen tables around posts and votes. A vote is keyed on post and customer, so each customer counts once, and a vote a team member adds on a customer's behalf must say where it came from. Revenue behind an idea is never stored: it is the monthly revenue of the distinct accounts whose customers voted, matched by email domain. Status changes are an append-only log, and a merged duplicate keeps a pointer to the idea it was merged into.

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

Copy the SQLDownload SQLDownload seed data

By Sam Claassen · From the Feature Requests blueprint · MIT licensed · Markdown version

Feature requests entity-relationship diagram

settingsidPK+ 5 more columnsteam_membersidPK+ 4 more columnsaccountsidPK+ 3 more columnscustomersidPKaccount_id→ accounts+ 4 more columnspostsidPKauthor_customer_id→ customersauthor_team_id→ team_membersmerged_into_id→ posts+ 7 more columnsvotespost_idPK → postscustomer_idPK → customersadded_by_team_id→ team_members+ 2 more columnsfollowspost_idPK → postscustomer_idPK → customers+ 1 more columncommentsidPKpost_id→ posts+ 6 more columnsstatus_changesidPKpost_id→ posts+ 6 more columnschangelog_entriesidPK+ 3 more columnschangelog_entry_postschangelog_entry_idPK → changel…post_idPK → postseventsidPK+ 5 more columnsnotificationsidPK+ 7 more columnssign_in_linksidPK+ 5 more columnssessionsidPKcustomer_id→ customersteam_member_id→ team_members+ 2 more columnssettingsidPK+ 5 more columnsteam_membersidPK+ 4 more columnsaccountsidPK+ 3 more columnscustomersidPKaccount_id→ accounts+ 4 more columnspostsidPKauthor_customer_id→ customersauthor_team_id→ team_membersmerged_into_id→ posts+ 7 more columnsvotespost_idPK → postscustomer_idPK → customersadded_by_team_id→ team_members+ 2 more columnsfollowspost_idPK → postscustomer_idPK → customers+ 1 more columncommentsidPKpost_id→ posts+ 6 more columnsstatus_changesidPKpost_id→ posts+ 6 more columnschangelog_entriesidPK+ 3 more columnschangelog_entry_postschangelog_entry_idPK → changel…post_idPK → postseventsidPK+ 5 more columnsnotificationsidPK+ 7 more columnssign_in_linksidPK+ 5 more columnssessionsidPKcustomer_id→ customersteam_member_id→ team_members+ 2 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

  • customers.account_id references accounts.id: each customers row points to at most one accounts row, and one accounts row can have many customers rows pointing to it.
  • posts.author_customer_id references customers.id: each posts row points to at most one customers row, and one customers row can have many posts rows pointing to it.
  • posts.author_team_id references team_members.id: each posts row points to at most one team_members row, and one team_members row can have many posts rows pointing to it.
  • posts.merged_into_id references posts.id: each posts row points to at most one another posts row, and one posts row can have many posts rows pointing to it.
  • votes.post_id references posts.id: each votes row points to exactly one posts row, and one posts row can have many votes rows pointing to it.
  • votes.customer_id references customers.id: each votes row points to exactly one customers row, and one customers row can have many votes rows pointing to it.
  • votes.added_by_team_id references team_members.id: each votes row points to at most one team_members row, and one team_members row can have many votes rows pointing to it.
  • follows.post_id references posts.id: each follows row points to exactly one posts row, and one posts row can have many follows rows pointing to it.
  • follows.customer_id references customers.id: each follows row points to exactly one customers row, and one customers row can have many follows rows pointing to it.
  • comments.post_id references posts.id: each comments row points to exactly one posts row, and one posts row can have many comments rows pointing to it.
  • status_changes.post_id references posts.id: each status_changes row points to exactly one posts row, and one posts row can have many status_changes rows pointing to it.
  • changelog_entry_posts.changelog_entry_id references changelog_entries.id: each changelog_entry_posts row points to exactly one changelog_entries row, and one changelog_entries row can have many changelog_entry_posts rows pointing to it.
  • changelog_entry_posts.post_id references posts.id: each changelog_entry_posts row points to exactly one posts row, and one posts row can have many changelog_entry_posts rows pointing to it.
  • sessions.customer_id references customers.id: each sessions row points to at most one customers row, and one customers row can have many sessions rows pointing to it.
  • sessions.team_member_id references team_members.id: each sessions row points to at most one team_members row, and one team_members row can have many sessions rows pointing to it.

Feature requests tables

The schema has 15 tables. Every column below is read from the SQL file itself. Also described as: feature voting board database design, product feedback database tables, idea board schema.

TableImplementsWhat a row is
settingsSettingsThe single row of board settings, including the team's email domain and the daily post limit.
team_membersTeamMemberSomeone on the product team, an admin or a member.
accountsAccountA paying customer company with its email domain and monthly revenue in cents.
customersCustomerA customer who signed in by email, matched to an account by domain.
postsPostAn idea on the board, with its status, latest status note, and the idea it was merged into, if any.
votesVoteOne customer's vote on one idea, possibly added by a team member on their behalf.
followsFollowA customer following an idea for status and comment emails.
commentsCommentA public or internal comment on an idea.
status_changesStatusChangeOne append-only change of an idea's status, with its note and who made it.
changelog_entriesChangelogEntryA changelog entry, a draft until it is published.
changelog_entry_postschild table of ChangelogEntryOne shipped idea linked from a changelog entry (the spec's post_ids list).
eventsEventAn append-only audit entry, including every export.
notificationsNotificationAn email in the outbox, written before it is sent, with its status.
sign_in_linksSignInLinkA one-time sign-in link, stored only as a hash of its token.
sessionsSessionA signed-in session for one customer or one team member.

settings

Board settings. Exactly one row.

ColumnTypeNullDefaultKeyNotes
idINTEGERnoPrimary keykeeps this table to one rowCheck: id = 1
company_nameTEXTno
board_titleTEXTno
from_emailTEXTyesthe From address of the board's emails
company_domainTEXTnoteam emails; these sign in to the admin area, never as customers
posts_per_day_limitINTEGERno5per customer per rolling 24 hours; 0 turns customer posting offCheck: posts_per_day_limit >= 0

team_members

Someone on the product team.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTno
emailTEXTnoUniqueon company_domain
roleTEXTnoCheck: role IN ('admin', 'member')
activeBOOLEANnoTRUE
  • App rule (section 4): only admins hide items, import accounts, change MRR, publish changelog entries and open the Outbox.

accounts

A paying customer company, imported from your account list. Revenue behind a post is computed from these rows.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
companyTEXTno
domainTEXTnoUniquecustomers are matched to an account by email domain
mrr_centsINTEGERnomonthly revenue in cents; imported as dollarsCheck: mrr_cents >= 0

customers

A customer who signed in with a one-time email link. Created at the first sign-in.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
emailTEXTnoUniquelowercase
nameTEXTyesoptional; refusals use the first name, or the email when no name is known
account_idTEXTyesReferences accounts.idNULL when the domain matches no account
created_atTIMESTAMPno
unsubscribed_atTIMESTAMPyesset: no status, merge, changelog or comment emails (sign-in links still go)
  • Table check: email = lower(email)
  • App rule (R1): account_id is matched by email domain at every sign-in and after every accounts import.

posts

An idea on the board. Posted by a customer or by a team member.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
numberINTEGERnoUniqueshown to people: #1, #2
titleTEXTnoCheck: length(title) BETWEEN 8 AND 120
bodyTEXTyes
author_customer_idTEXTyesReferences customers.id
author_team_idTEXTyesReferences team_members.id
statusTEXTno'under_review'Check: status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')
status_noteTEXTyesthe latest status change's note; a change without a note clears it
merged_into_idTEXTyesReferences posts.idset: this post is a merged duplicate and redirects to the target
hiddenBOOLEANnoFALSEhidden by an admin (R8)
created_atTIMESTAMPno
  • Table check: (author_customer_id IS NULL) <> (author_team_id IS NULL)
  • Table check: status <> 'declined' OR status_note IS NOT NULL
  • Table check: merged_into_id IS NULL OR merged_into_id <> id
  • App rule (R5): at most posts_per_day_limit new posts per customer in a rolling 24 hours.
  • App rule (section 6): merging into itself, an already merged idea or a hidden idea is refused; votes follow to the final target.

votes

One customer's vote on one post. Shipped and declined posts take no new votes (app rule).

ColumnTypeNullDefaultKeyNotes
post_idTEXTnoPrimary key (part); References posts.id
customer_idTEXTnoPrimary key (part); References customers.id
created_atTIMESTAMPno
added_by_team_idTEXTyesReferences team_members.idset when a team member voted on the customer's behalf (R7)
noteTEXTyeswhere a vote on the customer's behalf came from; required for those, absent otherwise
  • Table check: (added_by_team_id IS NULL) = (note IS NULL)

follows

A customer following a post, for status and comment emails.

ColumnTypeNullDefaultKeyNotes
post_idTEXTnoPrimary key (part); References posts.id
customer_idTEXTnoPrimary key (part); References customers.id
created_atTIMESTAMPno

comments

A comment on a post. Internal comments are team-only and never send email.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
post_idTEXTnoReferences posts.id
author_kindTEXTnoCheck: author_kind IN ('customer', 'team')
author_idTEXTnoa customers.id or team_members.id, by author_kind
bodyTEXTno
internalBOOLEANnoFALSE
hiddenBOOLEANnoFALSE
created_atTIMESTAMPno
  • Table check: internal = FALSE OR author_kind = 'team'

status_changes

One change of a post's status. Append-only (R10). The spec gives this entity no id; id is added so every row has a primary key, like the spec's other append-only logs. The spec's fields "from" and "to" are reserved words in SQL, so they are from_status and to_status.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
post_idTEXTnoReferences posts.id
from_statusTEXTnoCheck: from_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')
to_statusTEXTnoCheck: to_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')
noteTEXTyes
by_kindTEXTnoCheck: by_kind IN ('customer', 'team')
by_idTEXTno
atTIMESTAMPno
  • Table check: from_status <> to_status
  • Table check: to_status <> 'declined' OR note IS NOT NULL
  • Index status_changes_post on (post_id, at)

changelog_entries

A changelog entry. A draft until published; a published entry is never edited, deleted or published again.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
titleTEXTno
bodyTEXTyes
published_atTIMESTAMPyesNULL while a draft

changelog_entry_posts

The spec's post_ids list: one shipped post linked from a changelog entry.

ColumnTypeNullDefaultKeyNotes
changelog_entry_idTEXTnoPrimary key (part); References changelog_entries.id
post_idTEXTnoPrimary key (part); References posts.id
  • App rule (R6): only shipped posts that are not merged or hidden can be linked.

events

Audit log entry. Append-only (R10); exports write one too.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
atTIMESTAMPno
actor_kindTEXTyesCheck: actor_kind IN ('customer', 'team')
actor_idTEXTyesa customers.id or team_members.id, by actor_kind
typeTEXTno
dataTEXTyesdetails as JSON text
  • Table check: (actor_kind IS NULL) = (actor_id IS NULL)

notifications

An email in the outbox. Written here first, then sent; the Outbox lists newest first and blanks out sign-in links.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
kindTEXTnowhich email it is: one of the triggers in section 10
to_emailTEXTno
subjectTEXTno
bodyTEXTno
statusTEXTno'queued'logged when no provider is configuredCheck: status IN ('queued', 'sent', 'failed', 'logged')
errorTEXTyes
created_atTIMESTAMPno

A one-time sign-in link: valid for 15 minutes and used once (R1). Only the hash of the token is stored.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
emailTEXTno
token_hashTEXTnoUniquenever the link itself
created_atTIMESTAMPno
expires_atTIMESTAMPno
used_atTIMESTAMPyes
  • Index sign_in_links_email on (email, created_at)
  • App rule (section 13): at most 5 links per email per rolling 60 minutes.

sessions

A signed-in session for a customer or a team member; lasts 30 days.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
customer_idTEXTyesReferences customers.id
team_member_idTEXTyesReferences team_members.id
created_atTIMESTAMPno
expires_atTIMESTAMPno
  • Table check: (customer_id IS NULL) <> (team_member_id IS NULL)

The SQL

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

feature-requests.sql
-- Feature Requests database schema
-- Source: https://personalsoftwarefactory.com/blueprints/feature-requests (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.
-- Where the spec stores "a customer or a team member" (comment author, status change by, event actor), there are two columns: the kind and the id.

-- Board settings. Exactly one row.
CREATE TABLE settings (
  id INTEGER PRIMARY KEY CHECK (id = 1), -- keeps this table to one row
  company_name TEXT NOT NULL,
  board_title TEXT NOT NULL,
  from_email TEXT, -- the From address of the board's emails
  company_domain TEXT NOT NULL, -- team emails; these sign in to the admin area, never as customers
  posts_per_day_limit INTEGER NOT NULL DEFAULT 5 CHECK (posts_per_day_limit >= 0) -- per customer per rolling 24 hours; 0 turns customer posting off
);

-- Someone on the product team.
-- App rule (section 4): only admins hide items, import accounts, change MRR, publish changelog entries and open the Outbox.
CREATE TABLE team_members (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  email TEXT NOT NULL UNIQUE, -- on company_domain
  role TEXT NOT NULL CHECK (role IN ('admin', 'member')),
  active BOOLEAN NOT NULL DEFAULT TRUE
);

-- A paying customer company, imported from your account list. Revenue behind a post is computed from these rows.
CREATE TABLE accounts (
  id TEXT PRIMARY KEY,
  company TEXT NOT NULL,
  domain TEXT NOT NULL UNIQUE, -- customers are matched to an account by email domain
  mrr_cents INTEGER NOT NULL CHECK (mrr_cents >= 0) -- monthly revenue in cents; imported as dollars
);

-- A customer who signed in with a one-time email link. Created at the first sign-in.
-- App rule (R1): account_id is matched by email domain at every sign-in and after every accounts import.
CREATE TABLE customers (
  id TEXT PRIMARY KEY,
  email TEXT NOT NULL UNIQUE, -- lowercase
  name TEXT, -- optional; refusals use the first name, or the email when no name is known
  account_id TEXT REFERENCES accounts(id), -- NULL when the domain matches no account
  created_at TIMESTAMP NOT NULL,
  unsubscribed_at TIMESTAMP, -- set: no status, merge, changelog or comment emails (sign-in links still go)
  CHECK (email = lower(email))
);

-- An idea on the board. Posted by a customer or by a team member.
-- App rule (R5): at most posts_per_day_limit new posts per customer in a rolling 24 hours.
-- App rule (section 6): merging into itself, an already merged idea or a hidden idea is refused; votes follow to the final target.
CREATE TABLE posts (
  id TEXT PRIMARY KEY,
  number INTEGER NOT NULL UNIQUE, -- shown to people: #1, #2
  title TEXT NOT NULL CHECK (length(title) BETWEEN 8 AND 120),
  body TEXT,
  author_customer_id TEXT REFERENCES customers(id),
  author_team_id TEXT REFERENCES team_members(id),
  status TEXT NOT NULL DEFAULT 'under_review' CHECK (status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')),
  status_note TEXT, -- the latest status change's note; a change without a note clears it
  merged_into_id TEXT REFERENCES posts(id), -- set: this post is a merged duplicate and redirects to the target
  hidden BOOLEAN NOT NULL DEFAULT FALSE, -- hidden by an admin (R8)
  created_at TIMESTAMP NOT NULL,
  CHECK ((author_customer_id IS NULL) <> (author_team_id IS NULL)), -- exactly one author
  CHECK (status <> 'declined' OR status_note IS NOT NULL), -- declining requires a public reason
  CHECK (merged_into_id IS NULL OR merged_into_id <> id)
);

-- One customer's vote on one post. Shipped and declined posts take no new votes (app rule).
CREATE TABLE votes (
  post_id TEXT NOT NULL REFERENCES posts(id),
  customer_id TEXT NOT NULL REFERENCES customers(id),
  created_at TIMESTAMP NOT NULL,
  added_by_team_id TEXT REFERENCES team_members(id), -- set when a team member voted on the customer's behalf (R7)
  note TEXT, -- where a vote on the customer's behalf came from; required for those, absent otherwise
  PRIMARY KEY (post_id, customer_id),
  CHECK ((added_by_team_id IS NULL) = (note IS NULL))
);

-- A customer following a post, for status and comment emails.
CREATE TABLE follows (
  post_id TEXT NOT NULL REFERENCES posts(id),
  customer_id TEXT NOT NULL REFERENCES customers(id),
  created_at TIMESTAMP NOT NULL,
  PRIMARY KEY (post_id, customer_id)
);

-- A comment on a post. Internal comments are team-only and never send email.
CREATE TABLE comments (
  id TEXT PRIMARY KEY,
  post_id TEXT NOT NULL REFERENCES posts(id),
  author_kind TEXT NOT NULL CHECK (author_kind IN ('customer', 'team')),
  author_id TEXT NOT NULL, -- a customers.id or team_members.id, by author_kind
  body TEXT NOT NULL,
  internal BOOLEAN NOT NULL DEFAULT FALSE,
  hidden BOOLEAN NOT NULL DEFAULT FALSE,
  created_at TIMESTAMP NOT NULL,
  CHECK (internal = FALSE OR author_kind = 'team')
);

-- One change of a post's status. Append-only (R10).
-- The spec gives this entity no id; id is added so every row has a primary key, like the spec's other append-only logs.
-- The spec's fields "from" and "to" are reserved words in SQL, so they are from_status and to_status.
CREATE TABLE status_changes (
  id TEXT PRIMARY KEY,
  post_id TEXT NOT NULL REFERENCES posts(id),
  from_status TEXT NOT NULL CHECK (from_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')),
  to_status TEXT NOT NULL CHECK (to_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')),
  note TEXT,
  by_kind TEXT NOT NULL CHECK (by_kind IN ('customer', 'team')),
  by_id TEXT NOT NULL,
  at TIMESTAMP NOT NULL,
  CHECK (from_status <> to_status), -- choosing the status an idea already has is refused
  CHECK (to_status <> 'declined' OR note IS NOT NULL)
);

CREATE INDEX status_changes_post ON status_changes (post_id, at);

-- A changelog entry. A draft until published; a published entry is never edited, deleted or published again.
CREATE TABLE changelog_entries (
  id TEXT PRIMARY KEY,
  title TEXT NOT NULL,
  body TEXT,
  published_at TIMESTAMP -- NULL while a draft
);

-- The spec's post_ids list: one shipped post linked from a changelog entry.
-- App rule (R6): only shipped posts that are not merged or hidden can be linked.
CREATE TABLE changelog_entry_posts (
  changelog_entry_id TEXT NOT NULL REFERENCES changelog_entries(id),
  post_id TEXT NOT NULL REFERENCES posts(id),
  PRIMARY KEY (changelog_entry_id, post_id)
);

-- Audit log entry. Append-only (R10); exports write one too.
CREATE TABLE events (
  id TEXT PRIMARY KEY,
  at TIMESTAMP NOT NULL,
  actor_kind TEXT CHECK (actor_kind IN ('customer', 'team')),
  actor_id TEXT, -- a customers.id or team_members.id, by actor_kind
  type TEXT NOT NULL,
  data TEXT, -- details as JSON text
  CHECK ((actor_kind IS NULL) = (actor_id IS NULL))
);

-- An email in the outbox. Written here first, then sent; the Outbox lists newest first and blanks out sign-in links.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  kind TEXT NOT NULL, -- which email it is: one of the triggers in section 10
  to_email TEXT NOT NULL,
  subject TEXT NOT NULL,
  body TEXT NOT NULL,
  status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued', 'sent', 'failed', 'logged')), -- logged when no provider is configured
  error TEXT,
  created_at TIMESTAMP NOT NULL
);

-- A one-time sign-in link: valid for 15 minutes and used once (R1). Only the hash of the token is stored.
-- App rule (section 13): at most 5 links per email per rolling 60 minutes.
CREATE TABLE sign_in_links (
  id TEXT PRIMARY KEY,
  email TEXT NOT NULL,
  token_hash TEXT NOT NULL UNIQUE, -- never the link itself
  created_at TIMESTAMP NOT NULL,
  expires_at TIMESTAMP NOT NULL,
  used_at TIMESTAMP
);

CREATE INDEX sign_in_links_email ON sign_in_links (email, created_at);

-- A signed-in session for a customer or a team member; lasts 30 days.
CREATE TABLE sessions (
  id TEXT PRIMARY KEY,
  customer_id TEXT REFERENCES customers(id),
  team_member_id TEXT REFERENCES team_members(id),
  created_at TIMESTAMP NOT NULL,
  expires_at TIMESTAMP NOT NULL,
  CHECK ((customer_id IS NULL) <> (team_member_id IS NULL)) -- exactly one
);

Seed data

Loads the parts of section 14 the spec fully defines: the settings row for Quill (the spec gives no From address, so from_email is empty), team members Nina Shah and Omar Ali, and the four accounts with their monthly revenue. Left out: the six ideas, their 125 votes and the customers, because the spec makes all but five voters generated customers, gives each idea an author who is "one of its voters" without naming them, and gives no idea descriptions, creation dates or customer sign-up dates. For the same reason the comments, status history and the "Mentions in comments" changelog entry are left out. Outbox, events, links and sessions start empty.

Download feature-requests-seed.sql (7 rows). It loads with foreign keys enforced on both engines.

Load it

SQLite, into a new file:

sqlite3
curl -s https://personalsoftwarefactory.com/schemas/feature-requests.sql https://personalsoftwarefactory.com/schemas/feature-requests-seed.sql | sqlite3 feature_requests.db

PostgreSQL, into a new database:

psql
createdb feature_requests && curl -s https://personalsoftwarefactory.com/schemas/feature-requests.sql https://personalsoftwarefactory.com/schemas/feature-requests-seed.sql | psql -v ON_ERROR_STOP=1 feature_requests

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

Design decisions

One vote per customer per idea

Section 5 makes Vote unique on post and customer, so votes uses (post_id, customer_id) as its primary key. That also makes merging safe: moving a duplicate's votes to the target can skip customers who already voted there, which is how "Dark theme please" (3 votes) merged into "Dark mode" (48) gives 50, not 51 (section 6).

Votes on a customer's behalf carry their source

R7 lets a team member add a vote for a customer, records who added it, and requires a note on where the request came from. A CHECK ties the two together: added_by_team_id and note are both set or both empty, so a customer's own vote never has a note and a team-added vote always does.

Revenue behind an idea is computed, never stored

Section 6 defines it as the sum of mrr_cents over distinct accounts with at least one vote, worked out from current data, so an MRR change or a customer's new domain updates every idea at once (section 13). There is no revenue column; a query joins votes to customers to accounts and sums each account once.

"A customer or a team member" is a kind plus an id

From the build test · field report

Comment.author, StatusChange.by and Event.actor can each be a customer or a team member. The build test found the spec didn't say which they point to; the spec now stores the kind and the id. Those columns have no foreign key because one column can't reference two tables; posts and sessions, which the spec gives two separate id columns, use two foreign keys and a CHECK that exactly one is set.

Changelog links are a child table

From the build test · field report

The build test found ChangelogEntry had no draft state and didn't say how post_ids is stored. An empty published_at now means a draft, and the list of post ids is the changelog_entry_posts table, one row per linked idea. Which ideas may be linked (shipped, not merged or hidden, R6) depends on the post's current state, so the app checks it.

Status changes are a log with renamed columns

StatusChange is append-only and has no id in the spec; status_changes adds an id primary key so each row can be referenced, as the spec's other logs can. Its fields from and to are SQL reserved words, so they are from_status and to_status. CHECKs refuse a change to the status an idea already has (section 7) and a decline without a note.

Example queries

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

Accounts by monthly revenue (admin)

SQL
SELECT company, domain, mrr_cents FROM accounts ORDER BY mrr_cents DESC, company;

On the seed data: 4 rows, from Acme Books (acmebooks.example, 240000 cents) down to Pine Labs (30000).

Account match for a sign-in email's domain (R1)

SQL
SELECT a.company, a.mrr_cents FROM accounts a WHERE a.domain = 'acmebooks.example';

On the seed data: 1 row (Acme Books, 240000), the account Ana Lopez and Raj Mehta are matched to when they sign in.

Team members who can sign in to the admin area

SQL
SELECT t.name, t.email, t.role FROM team_members t JOIN settings s ON t.email LIKE '%@' || s.company_domain WHERE t.active = TRUE ORDER BY t.name;

On the seed data: 2 rows (Nina Shah, admin; Omar Ali, member).

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 Feature Requests blueprint, a free spec that also has the business rules, the screens, 4 phased build prompts and 17 acceptance checks for building the whole tool with an AI app builder. We built it from those prompts and the result passed 17 of 17 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.