survey_version_sections
Overview
Snapshots of the sections (major groups) belonging to a version. They hang off the version, not the survey, so rows are duplicated per version.
Table Definition
| Logical name | Physical name | Column | Type | PK | Relation | Unique | Nullable | Default | Notes |
|---|---|---|---|---|---|---|---|---|---|
| Section | survey_version_sections | id | uuid | โฏ | gen_random_uuid() | Re-assigned when the version changes | |||
| survey_version_id | uuid | survey_versions:id (cascade) | |||||||
| stable_section_id | uuid | gen_random_uuid() | Stable ID, carried over when a version is copied | ||||||
| title | varchar(255) | Section title | |||||||
| description | text | '' | Description | ||||||
| generated_by | varchar(255) | manual | Origin. manual / ้กไผผใปใฏใทใงใณ็ๆ and so on | ||||||
| sort_order | integer | Position within the version | |||||||
| created_at | timestamptz | now() | |||||||
| updated_at | timestamptz | now() |
Relations
- survey_version_id โ survey_versions.id (onDelete: cascade)
- Referenced by:
survey_version_questions.section_id(cascade)
Indexes
- Primary key (id)
- UNIQUE INDEX: survey_version_sections_version_order_idx (survey_version_id, sort_order)
Notes
- What the stable ID is for:
idchanges per version, so identifying the same section across versions requiresstable_section_id. Following it lets the system locate the corresponding section in the latest version even when the question library points at an older snapshot - Avoiding the unique constraint when reordering: because of the unique index on
(version ID, sort order), swapping positions goes through a temporary value before being finalized - Deleting a section cascade-deletes its questions, choices, branch rules, and visibility rules (a hard delete). The snapshots of earlier versions remain, so a rollback can restore them