create table user_assessment_access (
  id bigserial primary key,
  user_id bigint not null references users(id) on delete cascade,
  assessment_id bigint not null references assessments(id) on delete cascade,
  can_retake boolean not null default false,
  reopened_at timestamptz,
  reopen_note varchar(1000),
  unique(user_id, assessment_id)
);

create index idx_user_assessment_access_user on user_assessment_access(user_id);
create index idx_user_assessment_access_assessment on user_assessment_access(assessment_id);
