create table info_requests
(
    id          bigint IDENTITY(1,1) primary key,
    project_id bigint references projects(id),
    ticket_id bigint references tickets(id),
    client_id bigint references clients(id),
    user_id bigint references users(id),
    state nvarchar(200) not null,
    client_consent bit default 0 not null,
    name nvarchar(500) default '',
    phone nvarchar(20) default '',
    email nvarchar(500) default '',
    deleted     bit default 0,
    created_at  datetimeoffset  not null,
    updated_at  datetimeoffset not null ,
    deleted_at  datetimeoffset
);

CREATE INDEX info_requests_client_id_ticket_id_ix
    ON info_requests (ticket_id, client_id, id DESC);

alter table tickets add info_request_id bigint references info_requests(id);
alter table ticket_messages add info_request_id bigint references info_requests(id);
alter table chat_messages add info_request_id bigint references info_requests(id);
