Skip to content

external_logics

Overview

Branch logic imported from an external tool (CS's logic). One logic corresponds to one branch rule in the design tool.

Table Definition

Logical name Physical name Column Type PK Relation Unique Nullable Default Notes
External branch logic external_logics id uuid โ—ฏ gen_random_uuid()
external_question_id uuid external_questions:id (cascade)
external_id bigint Logic ID on the CS side
order_index integer โ—ฏ Evaluation order; higher wins. CS reorders by rewriting this
action_question_external_id bigint โ—ฏ Destination question ID (logic_action.question_id)
action_is_random boolean false Whether the destination is randomized (logic_action.is_random)
raw jsonb Raw JSON of the logic object

Relations

  • external_question_id โ†’ external_questions.id (onDelete: cascade)
  • Referenced by: external_logic_items.external_logic_id (cascade)

Indexes

  • Primary key (id)
  • UNIQUE INDEX: external_logics_question_external_id_idx (external_question_id, external_id)

Correspondence with the CS Branch Structure

CS Design tool
One logic One branch rule
Several logic_items within a logic Several conditions within a rule (AND)
Several logics on the same question Several rules (OR)
logic.order_index The rule's sort_order (first match wins)
logic_action.question_id Destination question code
logic_action.message The rule's message

Notes

  • Expressing AND / OR: CS has no structure for mixing AND and OR inside a single logic; it is the same flat structure as the design tool
  • Exclusive settings: pointing logic_action.question_id at the question's own ID and putting text in logic_action.message produces an exclusive setting that blocks progress
  • Randomized destinations: action_is_random and logic_random_destinations exist in CS but are not supported by this system (only is_random: false is sent)
  • Deletion semantics: in CS, PUT /questions/{id}/logics/import only updates the logics that were sent; logics that were not sent are not deleted. Deletion uses the dedicated DELETE /logics/{id}
  • raw also contains logic_action.message and the randomized-destination structure