-- User-defined labels for NAS documents and OCR photos

ALTER TABLE document_analytics
    ADD COLUMN IF NOT EXISTS user_labels TEXT[] DEFAULT '{}',
    ADD COLUMN IF NOT EXISTS label_notes TEXT,
    ADD COLUMN IF NOT EXISTS labeled_at TIMESTAMPTZ;

ALTER TABLE photo_imports
    ADD COLUMN IF NOT EXISTS user_labels TEXT[] DEFAULT '{}',
    ADD COLUMN IF NOT EXISTS label_notes TEXT,
    ADD COLUMN IF NOT EXISTS labeled_at TIMESTAMPTZ;

CREATE INDEX IF NOT EXISTS idx_doc_analytics_user_labels ON document_analytics USING GIN (user_labels);
CREATE INDEX IF NOT EXISTS idx_photo_imports_user_labels ON photo_imports USING GIN (user_labels);
