Customer testimonial management system database schema

Seven tables, built around testimonials, where CHECK constraints tie status to permission: approved and published rows must have consent, a withdrawn row keeps the exact wording the customer agreed to as evidence, and only a published testimonial can be featured. A partial unique index allows one featured testimonial, and the public wall reads status, consent and withdrawn_at together. Invitations and testimonials point at each other, so only one side has a foreign key.

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

Copy the SQLDownload SQLDownload seed data

By Sam Claassen · From the Testimonial Wall blueprint · MIT licensed · Markdown version

Testimonial wall entity-relationship diagram

peopleidPK+ 5 more columnssettingsidPK+ 7 more columnsinvitationsidPKcreated_by_id→ people+ 14 more columnstestimonialsidPKinvitation_id→ invitationsreviewed_by_id→ people+ 20 more columnseventsidPKactor_id→ people+ 7 more columnsnotificationsidPKperson_id→ peopletestimonial_id→ testimonialsinvitation_id→ invitations+ 9 more columnsform_attemptsidPK+ 2 more columnspeopleidPK+ 5 more columnssettingsidPK+ 7 more columnsinvitationsidPKcreated_by_id→ people+ 14 more columnstestimonialsidPKinvitation_id→ invitationsreviewed_by_id→ people+ 20 more columnseventsidPKactor_id→ people+ 7 more columnsnotificationsidPKperson_id→ peopletestimonial_id→ testimonialsinvitation_id→ invitations+ 9 more columnsform_attemptsidPK+ 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

  • invitations.created_by_id references people.id: each invitations row points to exactly one people row, and one people row can have many invitations rows pointing to it.
  • testimonials.invitation_id references invitations.id: each testimonials row points to at most one invitations row, and one invitations row can have at most one testimonials row pointing to it.
  • testimonials.reviewed_by_id references people.id: each testimonials row points to at most one people row, and one people row can have many testimonials 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.testimonial_id references testimonials.id: each notifications row points to at most one testimonials row, and one testimonials row can have many notifications rows pointing to it. On delete: cascade.
  • notifications.invitation_id references invitations.id: each notifications row points to at most one invitations row, and one invitations row can have many notifications rows pointing to it. On delete: cascade.

Testimonial wall tables

The schema has 7 tables. Every column below is read from the SQL file itself. Also described as: testimonial collection database design, customer reviews and consent database tables, testimonial wall schema.

TableImplementsWhat a row is
peoplePersonA staff member: member, moderator or admin. Customers have no account.
settingsSettingsThe single row of settings, including the versioned permission sentence shown next to the checkbox.
invitationsInvitationA personal link asking one customer for a testimonial, pre-filled with the words they already used.
testimonialsTestimonialA customer's words, rating and permission evidence, with its review and publishing status.
eventsEventOne append-only history entry for a testimonial or invitation, with who acted and any note.
notificationsNotificationAn email in the outbox, to a customer or staff member, with its status.
form_attemptsFormAttemptOne saved form submission's hashed IP and time, for rate limiting.

people

A staff member. Customers never have an account.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
nameTEXTnoCheck: length(trim(name)) >= 1
emailTEXTnoUniquelowercase
activeBOOLEANnoTRUE
created_atTIMESTAMPno
roleTEXTnoCheck: role IN ('member', 'moderator', 'admin')
  • Table check: email = lower(email)
  • App rule (section 10): nobody can deactivate themselves or change their own role.

settings

Company settings. Exactly one row.

ColumnTypeNullDefaultKeyNotes
idINTEGERnoPrimary keykeeps this table to one rowCheck: id = 1
company_nameTEXTnoCheck: length(trim(company_name)) BETWEEN 1 AND 80
wall_titleTEXTnoCheck: length(trim(wall_title)) BETWEEN 1 AND 80
form_introTEXTnoCheck: length(trim(form_intro)) BETWEEN 1 AND 500
permission_textTEXTnothe sentence next to the permission checkboxCheck: length(trim(permission_text)) BETWEEN 20 AND 500
permission_versionINTEGERno1Check: permission_version >= 1
form_openBOOLEANnoTRUE
time_zoneTEXTno'America/New_York'IANA name, for dates in emails and on public pages
  • App rule (R15): changing permission_text adds 1 to permission_version and writes a settings_changed event.

invitations

A personal link that asks one customer for a testimonial, pre-filled with what they already said.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
tokenTEXTnoUniquethe /share/<token> linkCheck: length(token) >= 24
created_by_idTEXTnoReferences people.id
nameTEXTnoCheck: length(trim(name)) BETWEEN 2 AND 80
emailTEXTno
companyTEXTyesoptional, pre-fills the form
job_titleTEXTyesoptional, pre-fills the form
prefill_quoteTEXTyesthe words the customer already usedCheck: length(trim(prefill_quote)) <= 1000
sourceTEXTnoCheck: source IN ('email', 'call', 'chat', 'other')
source_noteTEXTyesprivateCheck: length(trim(source_note)) <= 300
statusTEXTno'open'Check: status IN ('open', 'completed', 'cancelled', 'expired')
created_atTIMESTAMPnothe invitation email is queued then
expires_atTIMESTAMPnocreated_at plus 14 days
reminded_atTIMESTAMPyesset once, by the scheduled job after 72 hours
completed_atTIMESTAMPyes
testimonial_idTEXTyesUniquethe testimonial it produced; no foreign key because testimonials.invitation_id points back here
  • Table check: status <> 'completed' OR (completed_at IS NOT NULL AND testimonial_id IS NOT NULL)
  • App rule (R17): the link works only while open and before expires_at, even when the form is closed.

testimonials

A customer's testimonial. Customer wording and consent fields are never edited by staff (R3).

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
submitted_atTIMESTAMPno
updated_atTIMESTAMPno
nameTEXTnoCheck: length(trim(name)) BETWEEN 2 AND 80
emailTEXTnonever publicCheck: length(trim(email)) <= 254
companyTEXTyesCheck: length(trim(company)) <= 100
job_titleTEXTyeslabelled "Role" on the formCheck: length(trim(job_title)) <= 100
quoteTEXTnoplain text, line breaks kept, never rendered as HTMLCheck: length(trim(quote)) BETWEEN 20 AND 1000
ratingINTEGERyesNULL means no rating, never zero starsCheck: rating BETWEEN 1 AND 5
consentBOOLEANnoTRUE only when the customer ticked the box (R1, R2)
consent_textTEXTyesthe exact sentence agreed to; kept after a withdrawal as evidence
consent_versionINTEGERyes
consent_atTIMESTAMPyes
withdrawn_atTIMESTAMPyes
statusTEXTno'pending'Check: status IN ('pending', 'approved', 'rejected', 'published', 'withdrawn')
featuredBOOLEANnoFALSE
sourceTEXTnoCheck: source IN ('form', 'invitation')
invitation_idTEXTyesReferences invitations.id; Uniquean invitation produces at most one testimonial (R17)
manage_tokenTEXTnoUniquethe customer's private /t/<token> linkCheck: length(manage_token) >= 24
review_noteTEXTyesprivate; required (5 or more) on rejectCheck: length(trim(review_note)) <= 300
reviewed_by_idTEXTyesReferences people.id
reviewed_atTIMESTAMPyes
published_atTIMESTAMPyesthe most recent publish
  • Table check: (source = 'invitation') = (invitation_id IS NOT NULL)
  • Table check: consent = FALSE OR (consent_text IS NOT NULL AND consent_version IS NOT NULL AND consent_at IS NOT NULL)
  • Table check: consent = TRUE OR status = 'withdrawn' OR (consent_text IS NULL AND consent_version IS NULL AND consent_at IS NULL)
  • Table check: status NOT IN ('approved', 'published') OR consent = TRUE
  • Table check: (status = 'withdrawn') = (withdrawn_at IS NOT NULL)
  • Table check: status <> 'withdrawn' OR (consent = FALSE AND consent_at IS NOT NULL)
  • Table check: status NOT IN ('approved', 'published', 'rejected') OR (reviewed_by_id IS NOT NULL AND reviewed_at IS NOT NULL)
  • Table check: status <> 'rejected' OR (review_note IS NOT NULL AND length(trim(review_note)) >= 5)
  • Table check: status <> 'published' OR published_at IS NOT NULL
  • Table check: featured = FALSE OR status = 'published'
  • Unique index testimonials_one_featured on (featured) where featured = TRUE. R7: at most one testimonial is featured.
  • Index testimonials_status_submitted on (status, submitted_at)
  • App rule (R12): status checks and updates happen in one transaction.

events

Append-only history. Never copies the customer's quote, email or name. No foreign keys to testimonials or invitations: R14's deleted event keeps the old id after both rows are gone.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
testimonial_idTEXTyes
invitation_idTEXTyes
created_atTIMESTAMPno
actor_typeTEXTnoCheck: actor_type IN ('person', 'customer', 'system')
actor_idTEXTyesReferences people.idset when actor_type is person
typeTEXTnoCheck: type IN ('submitted', 'approved', 'rejected', 'published', 'unpublished', 'featured', 'unfeatured', 'withdrawn', 'deleted', 'invitation_created', 'invitation_completed', 'invitation_reminded', 'invitation_cancelled', 'invitation_expired', 'settings_changed')
noteTEXTyesa review or withdrawal note
dataTEXTyesJSON text, such as old and new permission_version
  • Table check: (actor_type = 'person') = (actor_id IS NOT NULL)
  • Index events_testimonial on (testimonial_id, created_at)

notifications

An email in the outbox. Written first, then sent; failed or stuck rows are retried by the hourly job. R14 removes a deleted testimonial's outbox rows, so both references cascade.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
to_emailTEXTno
person_idTEXTyesReferences people.idset for staff recipients
testimonial_idTEXTyesReferences testimonials.id, on delete cascadeNULL for invitation and invitation_reminder
invitation_idTEXTyesReferences invitations.id, on delete cascade
reply_toTEXTyesthe invitation creator's email, for invitation emails
kindTEXTnoCheck: kind IN ('submission_received', 'new_submission', 'invitation', 'invitation_reminder', 'published', 'withdrawal_confirmed', 'withdrawn_alert')
subjectTEXTno
bodyTEXTnoplain text
statusTEXTno'queued'logged when no provider is configuredCheck: status IN ('queued', 'sent', 'logged', 'failed')
created_atTIMESTAMPno
sent_atTIMESTAMPyes
errorTEXTyes

form_attempts

One saved form submission, for rate limiting (R16: at most 5 per IP hash per 60 minutes). Pruned after 24 hours.

ColumnTypeNullDefaultKeyNotes
idTEXTnoPrimary key
ip_hashTEXTnoSHA-256 of the IP plus a server secret; never the raw IP
created_atTIMESTAMPno
  • Index form_attempts_ip_hash on (ip_hash, created_at)

The SQL

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

testimonial-wall.sql
-- Testimonial Wall database schema
-- Source: https://personalsoftwarefactory.com/blueprints/testimonial-wall (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.
-- Text lengths are counted after trimming. Tokens are at least 24 URL-safe characters from a secure random generator.

-- A staff member. Customers never have an account.
-- App rule (section 10): nobody can deactivate themselves or change their own role.
CREATE TABLE people (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL CHECK (length(trim(name)) >= 1),
  email TEXT NOT NULL UNIQUE, -- lowercase
  active BOOLEAN NOT NULL DEFAULT TRUE,
  created_at TIMESTAMP NOT NULL,
  role TEXT NOT NULL CHECK (role IN ('member', 'moderator', 'admin')),
  CHECK (email = lower(email))
);

-- Company settings. Exactly one row.
-- App rule (R15): changing permission_text adds 1 to permission_version and writes a settings_changed event.
CREATE TABLE settings (
  id INTEGER PRIMARY KEY CHECK (id = 1), -- keeps this table to one row
  company_name TEXT NOT NULL CHECK (length(trim(company_name)) BETWEEN 1 AND 80),
  wall_title TEXT NOT NULL CHECK (length(trim(wall_title)) BETWEEN 1 AND 80),
  form_intro TEXT NOT NULL CHECK (length(trim(form_intro)) BETWEEN 1 AND 500),
  permission_text TEXT NOT NULL CHECK (length(trim(permission_text)) BETWEEN 20 AND 500), -- the sentence next to the permission checkbox
  permission_version INTEGER NOT NULL DEFAULT 1 CHECK (permission_version >= 1),
  form_open BOOLEAN NOT NULL DEFAULT TRUE,
  time_zone TEXT NOT NULL DEFAULT 'America/New_York' -- IANA name, for dates in emails and on public pages
);

-- A personal link that asks one customer for a testimonial, pre-filled with what they already said.
-- App rule (R17): the link works only while open and before expires_at, even when the form is closed.
CREATE TABLE invitations (
  id TEXT PRIMARY KEY,
  token TEXT NOT NULL UNIQUE CHECK (length(token) >= 24), -- the /share/<token> link
  created_by_id TEXT NOT NULL REFERENCES people(id),
  name TEXT NOT NULL CHECK (length(trim(name)) BETWEEN 2 AND 80),
  email TEXT NOT NULL,
  company TEXT, -- optional, pre-fills the form
  job_title TEXT, -- optional, pre-fills the form
  prefill_quote TEXT CHECK (length(trim(prefill_quote)) <= 1000), -- the words the customer already used
  source TEXT NOT NULL CHECK (source IN ('email', 'call', 'chat', 'other')),
  source_note TEXT CHECK (length(trim(source_note)) <= 300), -- private
  status TEXT NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'completed', 'cancelled', 'expired')),
  created_at TIMESTAMP NOT NULL, -- the invitation email is queued then
  expires_at TIMESTAMP NOT NULL, -- created_at plus 14 days
  reminded_at TIMESTAMP, -- set once, by the scheduled job after 72 hours
  completed_at TIMESTAMP,
  testimonial_id TEXT UNIQUE, -- the testimonial it produced; no foreign key because testimonials.invitation_id points back here
  CHECK (status <> 'completed' OR (completed_at IS NOT NULL AND testimonial_id IS NOT NULL))
);

-- A customer's testimonial. Customer wording and consent fields are never edited by staff (R3).
-- App rule (R12): status checks and updates happen in one transaction.
CREATE TABLE testimonials (
  id TEXT PRIMARY KEY,
  submitted_at TIMESTAMP NOT NULL,
  updated_at TIMESTAMP NOT NULL,
  name TEXT NOT NULL CHECK (length(trim(name)) BETWEEN 2 AND 80),
  email TEXT NOT NULL CHECK (length(trim(email)) <= 254), -- never public
  company TEXT CHECK (length(trim(company)) <= 100),
  job_title TEXT CHECK (length(trim(job_title)) <= 100), -- labelled "Role" on the form
  quote TEXT NOT NULL CHECK (length(trim(quote)) BETWEEN 20 AND 1000), -- plain text, line breaks kept, never rendered as HTML
  rating INTEGER CHECK (rating BETWEEN 1 AND 5), -- NULL means no rating, never zero stars
  consent BOOLEAN NOT NULL, -- TRUE only when the customer ticked the box (R1, R2)
  consent_text TEXT, -- the exact sentence agreed to; kept after a withdrawal as evidence
  consent_version INTEGER,
  consent_at TIMESTAMP,
  withdrawn_at TIMESTAMP,
  status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'rejected', 'published', 'withdrawn')),
  featured BOOLEAN NOT NULL DEFAULT FALSE,
  source TEXT NOT NULL CHECK (source IN ('form', 'invitation')),
  invitation_id TEXT UNIQUE REFERENCES invitations(id), -- an invitation produces at most one testimonial (R17)
  manage_token TEXT NOT NULL UNIQUE CHECK (length(manage_token) >= 24), -- the customer's private /t/<token> link
  review_note TEXT CHECK (length(trim(review_note)) <= 300), -- private; required (5 or more) on reject
  reviewed_by_id TEXT REFERENCES people(id),
  reviewed_at TIMESTAMP,
  published_at TIMESTAMP, -- the most recent publish
  CHECK ((source = 'invitation') = (invitation_id IS NOT NULL)),
  -- consent evidence is complete when given, and empty when never given
  CHECK (consent = FALSE OR (consent_text IS NOT NULL AND consent_version IS NOT NULL AND consent_at IS NOT NULL)),
  CHECK (consent = TRUE OR status = 'withdrawn' OR (consent_text IS NULL AND consent_version IS NULL AND consent_at IS NULL)),
  -- R4, R5: approved and published need consent. R8: withdrawn means consent FALSE, withdrawn_at set, not featured
  CHECK (status NOT IN ('approved', 'published') OR consent = TRUE),
  CHECK ((status = 'withdrawn') = (withdrawn_at IS NOT NULL)),
  CHECK (status <> 'withdrawn' OR (consent = FALSE AND consent_at IS NOT NULL)),
  CHECK (status NOT IN ('approved', 'published', 'rejected') OR (reviewed_by_id IS NOT NULL AND reviewed_at IS NOT NULL)),
  CHECK (status <> 'rejected' OR (review_note IS NOT NULL AND length(trim(review_note)) >= 5)),
  CHECK (status <> 'published' OR published_at IS NOT NULL),
  CHECK (featured = FALSE OR status = 'published') -- R7: only a published testimonial can be featured
);

-- R7: at most one testimonial is featured.
CREATE UNIQUE INDEX testimonials_one_featured ON testimonials (featured) WHERE featured = TRUE;
CREATE INDEX testimonials_status_submitted ON testimonials (status, submitted_at);

-- Append-only history. Never copies the customer's quote, email or name.
-- No foreign keys to testimonials or invitations: R14's deleted event keeps the old id after both rows are gone.
CREATE TABLE events (
  id TEXT PRIMARY KEY,
  testimonial_id TEXT,
  invitation_id TEXT,
  created_at TIMESTAMP NOT NULL,
  actor_type TEXT NOT NULL CHECK (actor_type IN ('person', 'customer', 'system')),
  actor_id TEXT REFERENCES people(id), -- set when actor_type is person
  type TEXT NOT NULL CHECK (type IN ('submitted', 'approved', 'rejected', 'published', 'unpublished', 'featured', 'unfeatured', 'withdrawn', 'deleted',
    'invitation_created', 'invitation_completed', 'invitation_reminded', 'invitation_cancelled', 'invitation_expired', 'settings_changed')),
  note TEXT, -- a review or withdrawal note
  data TEXT, -- JSON text, such as old and new permission_version
  CHECK ((actor_type = 'person') = (actor_id IS NOT NULL))
);

CREATE INDEX events_testimonial ON events (testimonial_id, created_at);

-- An email in the outbox. Written first, then sent; failed or stuck rows are retried by the hourly job.
-- R14 removes a deleted testimonial's outbox rows, so both references cascade.
CREATE TABLE notifications (
  id TEXT PRIMARY KEY,
  to_email TEXT NOT NULL,
  person_id TEXT REFERENCES people(id), -- set for staff recipients
  testimonial_id TEXT REFERENCES testimonials(id) ON DELETE CASCADE, -- NULL for invitation and invitation_reminder
  invitation_id TEXT REFERENCES invitations(id) ON DELETE CASCADE,
  reply_to TEXT, -- the invitation creator's email, for invitation emails
  kind TEXT NOT NULL CHECK (kind IN ('submission_received', 'new_submission', 'invitation', 'invitation_reminder', 'published', 'withdrawal_confirmed', 'withdrawn_alert')),
  subject TEXT NOT NULL,
  body TEXT NOT NULL, -- plain text
  status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued', 'sent', 'logged', 'failed')), -- logged when no provider is configured
  created_at TIMESTAMP NOT NULL,
  sent_at TIMESTAMP,
  error TEXT
);

-- One saved form submission, for rate limiting (R16: at most 5 per IP hash per 60 minutes). Pruned after 24 hours.
CREATE TABLE form_attempts (
  id TEXT PRIMARY KEY,
  ip_hash TEXT NOT NULL, -- SHA-256 of the IP plus a server secret; never the raw IP
  created_at TIMESTAMP NOT NULL
);

CREATE INDEX form_attempts_ip_hash ON form_attempts (ip_hash, created_at);

Seed data

Loads all of section 14 for Northwind: 4 staff, the settings row with permission wording version 1, the 10 testimonials with their words, permission evidence and review history, Ben's completed and Nora's open invitation, and 29 events matching the history (including the two invitations' creation and Ben's completion). The spec times everything from T, the moment the seed loads; this file fixes T at 2026-10-15 12:00 UTC and gives people that created_at. Tokens must be random, so the seed holds clearly marked placeholder tokens to replace. The outbox starts empty and there are no form attempts, as the spec says.

Download testimonial-wall-seed.sql (46 rows). It loads with foreign keys enforced on both engines.

Load it

SQLite, into a new file:

sqlite3
curl -s https://personalsoftwarefactory.com/schemas/testimonial-wall.sql https://personalsoftwarefactory.com/schemas/testimonial-wall-seed.sql | sqlite3 testimonial_wall.db

PostgreSQL, into a new database:

psql
createdb testimonial_wall && curl -s https://personalsoftwarefactory.com/schemas/testimonial-wall.sql https://personalsoftwarefactory.com/schemas/testimonial-wall-seed.sql | psql -v ON_ERROR_STOP=1 testimonial_wall

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

Design decisions

Status and permission are checked together

R4 and R5 make permission a condition of approving and publishing, and R1 and R2 say only the customer's checkbox sets consent. CHECKs make approved and published rows carry consent = TRUE with the exact consent_text, version and time, and make a row that never had consent carry none. A wrong status update therefore fails in the database, not only in the app.

Withdrawal keeps the evidence

R8 sets consent to FALSE, withdrawn_at to now, status to withdrawn and featured to FALSE in one transaction, but keeps consent_text, consent_version and consent_at as evidence of what was agreed and when. The CHECKs follow that: status withdrawn exactly when withdrawn_at is set, and a withdrawn row must still hold its consent time. It cannot be undone; the customer submits again.

One featured testimonial, enforced by the database

From the build test · field report

R7 allows at most one featured testimonial, only a published one, and asks for a unique index on featured where featured is true where the database supports partial indexes; both engines here do. The build test found R7 let a second moderator silently replace a featured testimonial; the spec now has the Feature request carry the one the moderator saw and refuse it if that changed, which stays in the app.

Invitations and testimonials point at each other

A testimonial records the invitation it came from and an invitation records the testimonial it produced (section 5), which is a cycle. The foreign key sits on testimonials.invitation_id, and invitations.testimonial_id is a plain column. Both are UNIQUE, because an invitation produces at most one testimonial (R17), and a CHECK ties source = invitation to having an invitation_id.

History survives a delete; the outbox does not

From the build test · field report

R14 lets an admin delete a rejected or withdrawn testimonial with its events, outbox rows and invitation, then write one deleted event that keeps the old id. So events has no foreign keys to testimonials or invitations, while notifications references both with ON DELETE CASCADE. The build test found a notification's testimonial had to be optional for invitation emails and the invitation's Reply-To had nowhere to live; testimonial_id is nullable and reply_to holds the creator's email.

Tokens and IP addresses

manage_token and invitation tokens are unique and at least 24 characters, from a secure random generator (section 5), because the link is the customer's only key. form_attempts stores a SHA-256 hash of the IP plus a server secret, never the raw IP, and the hourly job prunes rows older than 24 hours.

Example queries

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

The public wall (R9 and section 9)

SQL
SELECT name, job_title, company, rating, CASE WHEN featured THEN 'featured' ELSE '' END AS featured, quote FROM testimonials WHERE status = 'published' AND consent = TRUE AND withdrawn_at IS NULL ORDER BY CASE WHEN featured THEN 0 ELSE 1 END, submitted_at DESC;

On the seed data: 5 rows in the spec's order (Ana Moreno featured, then Theo Grant, Hugo Brandt, Rosa Lind, Ben Adler).

The wall with a minimum rating of 4

SQL
SELECT name, rating FROM testimonials WHERE status = 'published' AND consent = TRUE AND withdrawn_at IS NULL AND rating >= 4 ORDER BY CASE WHEN featured THEN 0 ELSE 1 END, submitted_at DESC;

On the seed data: 3 rows (Ana Moreno 5, Hugo Brandt 4, Ben Adler 5); Rosa Lind has no rating, so she appears only without a minimum.

Pending queue, oldest first

SQL
SELECT t.name, t.company, CASE WHEN t.consent THEN 'Permission to publish' ELSE 'Private: no permission' END AS permission, COALESCE('Invitation from ' || p.name, 'Form') AS source FROM testimonials t LEFT JOIN invitations i ON i.id = t.invitation_id LEFT JOIN people p ON p.id = i.created_by_id WHERE t.status = 'pending' ORDER BY t.submitted_at;

On the seed data: 2 rows (Cy Patel, Acme, Permission to publish, Form; Lee Hart, Ridgeway, Private: no permission, Form).

Invitations due a reminder, at T + 2 days

SQL
SELECT i.name, i.email, i.expires_at FROM invitations i WHERE i.status = 'open' AND i.reminded_at IS NULL AND i.created_at <= '2026-10-14 12:00:00' AND i.expires_at > '2026-10-17 12:00:00' ORDER BY i.created_at;

On the seed data, with now at 2026-10-17 12:00 UTC (72 hours after the invitation was created): 1 row (Nora Quinn, nora@lumenstudio.example, expires 2026-10-28 12:00 UTC).

A testimonial's history

SQL
SELECT e.created_at, e.type, e.actor_type, COALESCE(p.name, '') AS actor, COALESCE(e.note, '') AS note FROM events e LEFT JOIN people p ON p.id = e.actor_id WHERE e.testimonial_id = 't-felix' ORDER BY e.created_at, e.id;

On the seed data: 2 rows (submitted by the customer; rejected by Jo Park with the note "Names a client and their spend. We can't publish that.").

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