alter table clients
    add blocked number(1) default 0;
update clients set blocked = 0;
alter table clients
    add blocked_until varchar2(100);
alter table clients
    add blocked_at TIMESTAMP WITH TIME ZONE;
alter table clients
    add block_reason varchar2(255);
alter table clients
    add user_who_blocked_id number(19) references users (id);

alter table tickets
    add blocked number(1) default 0;
update tickets set blocked = 0;
alter table tickets
    add blocked_until varchar2(100);
alter table tickets
    add blocked_at TIMESTAMP WITH TIME ZONE;
alter table tickets
    add block_reason varchar2(255);
alter table tickets
    add user_who_blocked_id number(19) references users (id);

create table blocked_tickets
(
    ticket_id     number(19) primary key references tickets (id),
    blocked_until varchar2(100),
    deleted       number(1) default 0,
    changed_at    TIMESTAMP WITH TIME ZONE
);

create table blocked_clients
(
    client_id     number(19) primary key references clients (id),
    blocked_until varchar2(100),
    deleted       number(1) default 0,
    changed_at    TIMESTAMP WITH TIME ZONE
);

create table blocked_tickets_settings
(
    project_id               number(19) references projects (id) not null,
    first_assign_to_group    number(1) default true,
    first_assign_to_group_id number(19) references groups (id) default 1,
    next_assign_to_group     number(1) default 0,
    next_assign_to_group_id  number(19) references groups (id) default 1,
    close_next_with_reply    number(1) default true,
    close_next_reply         varchar2(255) default 'Извините, все операторы заняты',
    created_at               TIMESTAMP WITH TIME ZONE not null,
    updated_at               TIMESTAMP WITH TIME ZONE
);