Skip to content

survey_version_pointers

Overview

A pointer table recording which version a survey treats as its "latest". One row per survey and pointer type.

Table Definition

Logical name Physical name Column Type PK Relation Unique Nullable Default Notes
Version pointer survey_version_pointers survey_id uuid โ—ฏ surveys:id (cascade)
version_id uuid survey_versions:id (cascade) The version pointed at
pointer_type varchar(50) โ—ฏ Currently only latest

Relations

  • survey_id โ†’ surveys.id (onDelete: cascade)
  • version_id โ†’ survey_versions.id (onDelete: cascade)

Indexes

  • Composite primary key (survey_id, pointer_type)

Constraints

  • CHECK: survey_version_pointers_pointer_type_check โ€” pointer_type in ('latest')

Notes

  • The latest pointer is created when a survey is created and updated to the new version on every save and rollback
  • The composite primary key prevents a survey from holding more than one pointer of the same type
  • pointer_type is a varchar with a CHECK constraint rather than an enum, to leave room for future pointer types such as a "published version". Only latest is used today
  • In practice, identifying the latest version also uses surveys.latest_version_no