CREATE TABLE IF NOT EXISTS import_log (
  id          SERIAL PRIMARY KEY,
  client_id   TEXT        NOT NULL,
  entity_id   TEXT        NOT NULL,
  user_email  TEXT        NOT NULL,
  action      TEXT        NOT NULL CHECK (action IN ('import', 'sync')),
  prev_score  NUMERIC(5,2),
  new_score   NUMERIC(5,2),
  filename    TEXT,
  logged_at   TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS import_log_client_logged ON import_log (client_id, logged_at DESC);
