-- SQL to create calibration_audit table in Supabase
CREATE TABLE IF NOT EXISTS calibration_audit (
  id BIGSERIAL PRIMARY KEY,
  calibration_id UUID REFERENCES calibrations(id),
  user_id UUID REFERENCES users(id),
  action TEXT NOT NULL,
  old_values JSONB,
  new_values JSONB,
  timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  ip_address TEXT
);

CREATE INDEX IF NOT EXISTS idx_calibration_audit_calibration_id ON calibration_audit(calibration_id);
CREATE INDEX IF NOT EXISTS idx_calibration_audit_user_id ON calibration_audit(user_id);
CREATE INDEX IF NOT EXISTS idx_calibration_audit_timestamp ON calibration_audit(timestamp);
