create table info_requests
(
    id          bigint 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 varchar(200) not null,
    client_consent bool default false not null,
    name varchar(500) default '',
    phone varchar(500) default '',
    email varchar(500) default '',
    deleted     boolean default false,
    created_at  timestamptz  not null,
    updated_at  timestamptz,
    deleted_at  timestamptz
);

create sequence info_requests_id_seq;

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

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