ALTER TABLE mesh_latest_links
    ADD COLUMN IF NOT EXISTS observation_key TEXT NOT NULL DEFAULT 'default';

ALTER TABLE mesh_latest_links
    DROP CONSTRAINT IF EXISTS mesh_latest_links_pkey;

ALTER TABLE mesh_latest_links
    ADD PRIMARY KEY (cluster_id, source_node_id, target_node_id, observation_key);

CREATE INDEX IF NOT EXISTS idx_mesh_latest_links_cluster_observed
    ON mesh_latest_links(cluster_id, observed_at DESC);
