-- Add event_id and department_id to documents for auto-folder linking
ALTER TABLE documents ADD COLUMN IF NOT EXISTS event_id uuid REFERENCES events(id) ON DELETE SET NULL;
ALTER TABLE documents ADD COLUMN IF NOT EXISTS department_id uuid REFERENCES event_departments(id) ON DELETE SET NULL;

-- Index for quick lookups
CREATE INDEX IF NOT EXISTS idx_documents_event_id ON documents(event_id) WHERE event_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_documents_department_id ON documents(department_id) WHERE department_id IS NOT NULL;
