-- Add step details to letter_outgoing_approvals table
ALTER TABLE letter_outgoing_approvals 
ADD COLUMN IF NOT EXISTS step_order INT NOT NULL DEFAULT 1,
ADD COLUMN IF NOT EXISTS parallel_group INT DEFAULT 1,
ADD COLUMN IF NOT EXISTS is_required BOOLEAN DEFAULT true;

-- Add indexes for better query performance
CREATE INDEX IF NOT EXISTS idx_letter_outgoing_approvals_step_order 
ON letter_outgoing_approvals(letter_id, step_order);

CREATE INDEX IF NOT EXISTS idx_letter_outgoing_approvals_parallel_group 
ON letter_outgoing_approvals(letter_id, parallel_group);

-- Add comments for documentation
COMMENT ON COLUMN letter_outgoing_approvals.step_order IS 'The order in which this approval step should be processed';
COMMENT ON COLUMN letter_outgoing_approvals.parallel_group IS 'Steps with the same parallel_group value can be processed simultaneously';
COMMENT ON COLUMN letter_outgoing_approvals.is_required IS 'Whether this approval step is required for the letter to proceed';