-- Migration: Add watermark_logs support for documents table (UUID)
-- 035_watermark_logs_documents.sql
-- Adds document_id column to watermark_logs to support documents table

-- Add document_id column to watermark_logs for documents table (UUID)
ALTER TABLE watermark_logs ADD COLUMN IF NOT EXISTS document_id UUID REFERENCES documents(id) ON DELETE CASCADE;

-- Create index for document_id
CREATE INDEX IF NOT EXISTS idx_watermark_logs_document_id ON watermark_logs(document_id) WHERE document_id IS NOT NULL;

-- Update comments
COMMENT ON COLUMN watermark_logs.document_id IS 'Reference to documents table (UUID) for discovery documents';
COMMENT ON COLUMN watermark_logs.file_id IS 'Reference to scan_files table (INTEGER) for legacy scans';

