create table wait_tickets(
                             ticket_id BIGINT NOT NULL references tickets(id),
                             deleted BIT not null,
                             user_id BIGINT NOT NULL references users(id),
                             wait_until DATETIMEOFFSET NOT NULL,
                             changed_at DATETIMEOFFSET not null
);
create unique index wait_tickets_ticket_id on wait_tickets(ticket_id);

alter table tickets add has_wait_ticket BIT;
alter table tickets add notify_wait_return BIT;
