--- target-violations

create table target_violations (
    id bigint primary key identity(1, 1),
    project_id bigint not null references projects(id),
    target_id bigint not null references targets(id),
    user_id bigint not null references users(id),

    ticket_id bigint references tickets(id),
    status_id bigint references statuses(id),
    resolved bit not null,

    created_at datetimeoffset not null,
    updated_at datetimeoffset not null,
    started_at datetimeoffset not null
);

create index target_violations_project_started_ix 
on target_violations(project_id, started_at);

create index target_violations_target_ticket_user_ix 
on target_violations(target_id, ticket_id, user_id);

create index target_violations_target_status_ix
on target_violations(target_id, status_id);
