-- 075: Create bulk_enrichment_jobs table for tracking batch enrichment operations
-- Run: python3 scripts/run_migration.py database/migrations/075_bulk_enrichment_jobs.sql

CREATE TABLE IF NOT EXISTS bulk_enrichment_jobs (
    id SERIAL PRIMARY KEY,
    started_at TIMESTAMP DEFAULT NOW(),
    started_by INTEGER REFERENCES users(id),
    status VARCHAR(20) DEFAULT 'running',
    total_companies INTEGER DEFAULT 0,
    processed_companies INTEGER DEFAULT 0,
    steps JSONB,
    results JSONB DEFAULT '{}'::jsonb,
    completed_at TIMESTAMP
);

GRANT ALL ON TABLE bulk_enrichment_jobs TO nordabiz_app;
GRANT USAGE, SELECT ON SEQUENCE bulk_enrichment_jobs_id_seq TO nordabiz_app;
