form_submissions

This table stores completed or draft instances of forms filled out by users. Each row represents one submission event for a specific template and project.

Domain: Workflow Engine / Forms
Scope: Tenant / Project
Status: Proposed
Last Updated: 11 Apr 2026
Mutable: Draft yes, submitted no
Primary Owner: Forms Service / Core API
RLS Applies: Yes
Client Facing: Yes

Purpose

The purpose of this table is to persist the user-submitted data for a form, including the template version used, the project context, and the submitted payload.

What this table does

  • Stores one completed or draft form instance
  • Preserves the template snapshot used at submission time
  • Supports immutable submitted records
  • Acts as the main source for form history, PDF generation, and notifications

Why this table is defined

DirtView needs submissions to remain valid even when templates evolve later. That means submissions must store their own payload and template version context, independent from future template edits.

Columns

Column Type Required Description Example
iduuidYesPrimary key for the submissionfsub_001
tenant_iduuidYesTenant owning the submissiontenant_001
project_iduuidYesProject contextproject_phoenix
template_iduuidYesSource templateftpl_001
template_versionintYesTemplate version used1
statustextYesDraft/submitted/final/etc.submitted
datajsonbYesSubmitted field data payload{"crew":["e1","e2"],"hours":8}
schema_snapshotjsonbYesTemplate schema snapshot at submission time{"fields":[...]}
submitted_byuuidNoUser who created/submitted the formuser_123
submitted_attimestamptzNoTimestamp of submission2026-04-11 13:00:00+00
distribution_group_iduuidNoResolved distribution group for notificationsdgroup_015
pdf_file_iduuidNoGenerated branded PDF outputfile_501
metadatajsonbYesAdditional submission metadata{"device":"mobile"}
created_attimestamptzYesCreation timestamp2026-04-11 12:40:00+00
updated_attimestamptzYesLast update timestamp2026-04-11 13:00:00+00

Relationships

How it is used

  • Rendered in form history and submission detail views
  • Used to generate branded PDFs
  • Used to trigger notifications and reports
  • Queried for search/filter/reporting across projects and users

Access and security

  • Submitted forms should usually be immutable
  • Drafts may be editable until explicitly submitted
  • Access must respect project membership and field-level visibility rules where applicable

Example scenarios

Scenario 1: Mobile Daily Log submission

A foreman completes and submits a Daily Log on mobile, storing all field data in one submission row.

Scenario 2: Draft saved

A partially completed form remains in draft until later submission.

Scenario 3: PDF export

After submission, a branded PDF is generated and linked back to the submission.

Notes and assumptions

  • Submitted records should remain valid even if the template changes later
  • Store snapshots deliberately to preserve historical meaning
  • Consider indexing (project_id, template_id, submitted_at)