create table consent_logs (
  id bigserial primary key,
  user_id bigint not null references users(id) on delete cascade,
  consent_type varchar(64) not null,
  consent_version varchar(64) not null,
  granted boolean not null,
  ip_address varchar(128) not null,
  user_agent text not null,
  created_at timestamptz not null default now()
);

create index idx_consent_user_type_version on consent_logs(user_id, consent_type, consent_version);
create index idx_consent_created_at on consent_logs(created_at desc);
