CREATE TABLE IF NOT EXISTS crawl_run_employee_changes (
  id SERIAL PRIMARY KEY,
  crawl_run_id INTEGER NOT NULL REFERENCES crawl_runs(id),
  employee_id INTEGER REFERENCES employees(id),
  profile_key VARCHAR(255) NOT NULL,
  profile_url TEXT NOT NULL,
  full_name TEXT,
  change_type VARCHAR(32) NOT NULL,
  profile_available BOOLEAN,
  message TEXT,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS ix_crawl_run_employee_changes_run_id
  ON crawl_run_employee_changes (crawl_run_id);

CREATE INDEX IF NOT EXISTS ix_crawl_run_employee_changes_employee_id
  ON crawl_run_employee_changes (employee_id);

CREATE INDEX IF NOT EXISTS ix_crawl_run_employee_changes_change_type
  ON crawl_run_employee_changes (change_type);
