-- Migration: Add missao_pai_id to missao_logistica
-- This field links a Loading (CARREGAMENTO) mission to its parent Separation (SEPARACAO) mission.

BEGIN;

ALTER TABLE missao_logistica ADD COLUMN missao_pai_id INTEGER REFERENCES missao_logistica(id) ON DELETE SET NULL;

-- Index for performance on joins/filters
CREATE INDEX idx_missao_pai_id ON missao_logistica (missao_pai_id);

COMMIT;
