# Feature request tracking system database schema

Source: https://personalsoftwarefactory.com/schemas/feature-requests
Updated: 2026-12-04

> 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) on 2026-12-04
- 7 seed rows from the blueprint
- The blueprint's test build passed 17 of 17 acceptance checks

Files: [feature-requests.sql](https://personalsoftwarefactory.com/schemas/feature-requests.sql) · [feature-requests-seed.sql](https://personalsoftwarefactory.com/schemas/feature-requests-seed.sql) · [the Feature Requests blueprint](https://personalsoftwarefactory.com/blueprints/feature-requests)

## 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.

## Tables

Also described as: feature voting board database design, product feedback database tables, idea board schema.

### settings

The single row of board settings, including the team's email domain and the daily post limit. Implements: Settings.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | INTEGER | no |  | Primary key | keeps this table to one row Check: `id = 1` |
| `company_name` | TEXT | no |  |  |  |
| `board_title` | TEXT | no |  |  |  |
| `from_email` | TEXT | yes |  |  | the From address of the board's emails |
| `company_domain` | TEXT | no |  |  | team emails; these sign in to the admin area, never as customers |
| `posts_per_day_limit` | INTEGER | no | `5` |  | per customer per rolling 24 hours; 0 turns customer posting off Check: `posts_per_day_limit >= 0` |

### team_members

Someone on the product team, an admin or a member. Implements: TeamMember.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `name` | TEXT | no |  |  |  |
| `email` | TEXT | no |  | Unique | on company_domain |
| `role` | TEXT | no |  |  | Check: `role IN ('admin', 'member')` |
| `active` | BOOLEAN | no | `TRUE` |  |  |

- App rule (section 4): only admins hide items, import accounts, change MRR, publish changelog entries and open the Outbox.

### accounts

A paying customer company with its email domain and monthly revenue in cents. Implements: Account.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `company` | TEXT | no |  |  |  |
| `domain` | TEXT | no |  | Unique | customers are matched to an account by email domain |
| `mrr_cents` | INTEGER | no |  |  | monthly revenue in cents; imported as dollars Check: `mrr_cents >= 0` |

### customers

A customer who signed in by email, matched to an account by domain. Implements: Customer.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `email` | TEXT | no |  | Unique | lowercase |
| `name` | TEXT | yes |  |  | optional; refusals use the first name, or the email when no name is known |
| `account_id` | TEXT | yes |  | References accounts.id | NULL when the domain matches no account |
| `created_at` | TIMESTAMP | no |  |  |  |
| `unsubscribed_at` | TIMESTAMP | yes |  |  | set: 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, with its status, latest status note, and the idea it was merged into, if any. Implements: Post.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `number` | INTEGER | no |  | Unique | shown to people: #1, #2 |
| `title` | TEXT | no |  |  | Check: `length(title) BETWEEN 8 AND 120` |
| `body` | TEXT | yes |  |  |  |
| `author_customer_id` | TEXT | yes |  | References customers.id |  |
| `author_team_id` | TEXT | yes |  | References team_members.id |  |
| `status` | TEXT | no | `'under_review'` |  | Check: `status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')` |
| `status_note` | TEXT | yes |  |  | the latest status change's note; a change without a note clears it |
| `merged_into_id` | TEXT | yes |  | References posts.id | set: this post is a merged duplicate and redirects to the target |
| `hidden` | BOOLEAN | no | `FALSE` |  | hidden by an admin (R8) |
| `created_at` | TIMESTAMP | no |  |  |  |

- 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 idea, possibly added by a team member on their behalf. Implements: Vote.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `post_id` | TEXT | no |  | Primary key (part); References posts.id |  |
| `customer_id` | TEXT | no |  | Primary key (part); References customers.id |  |
| `created_at` | TIMESTAMP | no |  |  |  |
| `added_by_team_id` | TEXT | yes |  | References team_members.id | set when a team member voted on the customer's behalf (R7) |
| `note` | TEXT | yes |  |  | where 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 an idea for status and comment emails. Implements: Follow.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `post_id` | TEXT | no |  | Primary key (part); References posts.id |  |
| `customer_id` | TEXT | no |  | Primary key (part); References customers.id |  |
| `created_at` | TIMESTAMP | no |  |  |  |

### comments

A public or internal comment on an idea. Implements: Comment.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `post_id` | TEXT | no |  | References posts.id |  |
| `author_kind` | TEXT | no |  |  | Check: `author_kind IN ('customer', 'team')` |
| `author_id` | TEXT | no |  |  | a customers.id or team_members.id, by author_kind |
| `body` | TEXT | no |  |  |  |
| `internal` | BOOLEAN | no | `FALSE` |  |  |
| `hidden` | BOOLEAN | no | `FALSE` |  |  |
| `created_at` | TIMESTAMP | no |  |  |  |

- Table check: `internal = FALSE OR author_kind = 'team'`

### status_changes

One append-only change of an idea's status, with its note and who made it. Implements: StatusChange.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `post_id` | TEXT | no |  | References posts.id |  |
| `from_status` | TEXT | no |  |  | Check: `from_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')` |
| `to_status` | TEXT | no |  |  | Check: `to_status IN ('under_review', 'planned', 'in_progress', 'shipped', 'declined')` |
| `note` | TEXT | yes |  |  |  |
| `by_kind` | TEXT | no |  |  | Check: `by_kind IN ('customer', 'team')` |
| `by_id` | TEXT | no |  |  |  |
| `at` | TIMESTAMP | no |  |  |  |

- 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 it is published. Implements: ChangelogEntry.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `title` | TEXT | no |  |  |  |
| `body` | TEXT | yes |  |  |  |
| `published_at` | TIMESTAMP | yes |  |  | NULL while a draft |

### changelog_entry_posts

One shipped idea linked from a changelog entry (the spec's post_ids list). Implements: child table of ChangelogEntry.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `changelog_entry_id` | TEXT | no |  | Primary key (part); References changelog_entries.id |  |
| `post_id` | TEXT | no |  | Primary key (part); References posts.id |  |

- App rule (R6): only shipped posts that are not merged or hidden can be linked.

### events

An append-only audit entry, including every export. Implements: Event.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `at` | TIMESTAMP | no |  |  |  |
| `actor_kind` | TEXT | yes |  |  | Check: `actor_kind IN ('customer', 'team')` |
| `actor_id` | TEXT | yes |  |  | a customers.id or team_members.id, by actor_kind |
| `type` | TEXT | no |  |  |  |
| `data` | TEXT | yes |  |  | details as JSON text |

- Table check: `(actor_kind IS NULL) = (actor_id IS NULL)`

### notifications

An email in the outbox, written before it is sent, with its status. Implements: Notification.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `kind` | TEXT | no |  |  | which email it is: one of the triggers in section 10 |
| `to_email` | TEXT | no |  |  |  |
| `subject` | TEXT | no |  |  |  |
| `body` | TEXT | no |  |  |  |
| `status` | TEXT | no | `'queued'` |  | logged when no provider is configured Check: `status IN ('queued', 'sent', 'failed', 'logged')` |
| `error` | TEXT | yes |  |  |  |
| `created_at` | TIMESTAMP | no |  |  |  |

### sign_in_links

A one-time sign-in link, stored only as a hash of its token. Implements: SignInLink.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `email` | TEXT | no |  |  |  |
| `token_hash` | TEXT | no |  | Unique | never the link itself |
| `created_at` | TIMESTAMP | no |  |  |  |
| `expires_at` | TIMESTAMP | no |  |  |  |
| `used_at` | TIMESTAMP | yes |  |  |  |

- 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 one customer or one team member. Implements: Session.

| Column | Type | Null | Default | Key | Notes |
|---|---|---|---|---|---|
| `id` | TEXT | no |  | Primary key |  |
| `customer_id` | TEXT | yes |  | References customers.id |  |
| `team_member_id` | TEXT | yes |  | References team_members.id |  |
| `created_at` | TIMESTAMP | no |  |  |  |
| `expires_at` | TIMESTAMP | no |  |  |  |

- Table check: `(customer_id IS NULL) <> (team_member_id IS NULL)`

## The SQL

```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.

## Load it

```sh
# SQLite
curl -s https://personalsoftwarefactory.com/schemas/feature-requests.sql https://personalsoftwarefactory.com/schemas/feature-requests-seed.sql | sqlite3 feature_requests.db
# PostgreSQL
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
```

## 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

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. (This point comes from a gap the blueprint's build test found.)

### Changelog links are a child table

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. (This point comes from a gap the blueprint's build test found.)

### 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

### 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 is section 5 of the [Feature Requests blueprint](https://personalsoftwarefactory.com/blueprints/feature-requests), which also has the business rules, the screens, the phased build prompts and the acceptance checks. Paste-ready spec: https://personalsoftwarefactory.com/blueprints/feature-requests/blueprint.md
