-- Persist all presentation semantics required by the database-driven SVG.

ALTER TABLE topology.diagram_nodes
    ADD COLUMN IF NOT EXISTS display_meta text,
    ADD COLUMN IF NOT EXISTS display_hint text,
    ADD COLUMN IF NOT EXISTS decorations jsonb NOT NULL DEFAULT '{}'::jsonb;

CREATE TABLE IF NOT EXISTS topology.diagram_node_members (
    diagram_node_id uuid NOT NULL
        REFERENCES topology.diagram_nodes(id) ON DELETE CASCADE,
    component_id uuid NOT NULL
        REFERENCES topology.components(id),
    display_order integer NOT NULL DEFAULT 0,
    PRIMARY KEY (diagram_node_id, component_id)
);

CREATE INDEX IF NOT EXISTS idx_diagram_node_members_component
    ON topology.diagram_node_members(component_id);
