36 lines
1.3 KiB
SQL
36 lines
1.3 KiB
SQL
-- =============================================================================
|
|
-- Migration: 008_add_job_id_to_pipeline_tables.sql
|
|
-- Purpose: Add job_id column to pipeline tables for filtering by execution
|
|
-- =============================================================================
|
|
|
|
-- Add job_id to reviews_enriched
|
|
ALTER TABLE pipeline.reviews_enriched
|
|
ADD COLUMN IF NOT EXISTS job_id UUID;
|
|
|
|
-- Add index for job_id on reviews_enriched
|
|
CREATE INDEX IF NOT EXISTS idx_reviews_enriched_job_id
|
|
ON pipeline.reviews_enriched(job_id)
|
|
WHERE job_id IS NOT NULL;
|
|
|
|
-- Add job_id to review_spans
|
|
ALTER TABLE pipeline.review_spans
|
|
ADD COLUMN IF NOT EXISTS job_id UUID;
|
|
|
|
-- Add index for job_id on review_spans
|
|
CREATE INDEX IF NOT EXISTS idx_review_spans_job_id
|
|
ON pipeline.review_spans(job_id)
|
|
WHERE job_id IS NOT NULL;
|
|
|
|
-- Add job_id to issues
|
|
ALTER TABLE pipeline.issues
|
|
ADD COLUMN IF NOT EXISTS job_id UUID;
|
|
|
|
-- Add index for job_id on issues
|
|
CREATE INDEX IF NOT EXISTS idx_issues_job_id
|
|
ON pipeline.issues(job_id)
|
|
WHERE job_id IS NOT NULL;
|
|
|
|
COMMENT ON COLUMN pipeline.reviews_enriched.job_id IS 'Scraper job ID for filtering by execution';
|
|
COMMENT ON COLUMN pipeline.review_spans.job_id IS 'Scraper job ID for filtering by execution';
|
|
COMMENT ON COLUMN pipeline.issues.job_id IS 'Scraper job ID for filtering by execution';
|