-- Drop triggers
DROP TRIGGER IF EXISTS update_letter_summary_on_incoming ON letters_incoming;
DROP TRIGGER IF EXISTS update_letter_summary_on_outgoing ON letters_outgoing;

-- Drop functions
DROP FUNCTION IF EXISTS update_letter_summary();
DROP FUNCTION IF EXISTS populate_letter_summary_history();

-- Drop indexes
DROP INDEX IF EXISTS idx_letter_summary_date;
DROP INDEX IF EXISTS idx_letter_summary_type_date;
DROP INDEX IF EXISTS idx_dept_letter_summary_dept_date;
DROP INDEX IF EXISTS idx_dept_letter_summary_date;
DROP INDEX IF EXISTS idx_inst_letter_summary_inst_date;
DROP INDEX IF EXISTS idx_inst_letter_summary_date;
DROP INDEX IF EXISTS idx_approval_sla_summary_date;
DROP INDEX IF EXISTS idx_approval_sla_summary_dept_date;

-- Drop tables
DROP TABLE IF EXISTS approval_sla_summary;
DROP TABLE IF EXISTS institution_letter_summary;
DROP TABLE IF EXISTS department_letter_summary;
DROP TABLE IF EXISTS letter_summary;