alter table clients
    add blocked bit default 0;
update clients set blocked = 0;
alter table clients
    add blocked_until nvarchar(100);
alter table clients
    add blocked_at DATETIMEOFFSET;
alter table clients
    add block_reason nvarchar(255);
alter table clients
    add user_who_blocked_id bigint references users (id);

alter table tickets
    add blocked bit default 0;
update tickets set blocked = 0
alter table tickets
    add blocked_until nvarchar(100);
alter table tickets
    add blocked_at DATETIMEOFFSET;
alter table tickets
    add block_reason nvarchar(255);
alter table tickets
    add user_who_blocked_id bigint references users (id);

create table blocked_tickets
(
    ticket_id     bigint primary key references tickets (id),
    blocked_until nvarchar(100),
    deleted       bit default 0,
    changed_at    DATETIMEOFFSET
);

create table blocked_clients
(
    client_id     bigint primary key references clients (id),
    blocked_until nvarchar(100),
    deleted       bit default 0,
    changed_at    DATETIMEOFFSET
);

create table blocked_tickets_settings
(
    project_id               bigint references projects(id) not null,
    first_assign_to_group    bit,
    first_assign_to_group_id bigint,
    next_assign_to_group     bit,
    next_assign_to_group_id  bigint,
    close_next_with_reply    bit,
    close_next_reply         nvarchar(255),
    created_at               DATETIMEOFFSET not null,
    updated_at               DATETIMEOFFSET
);
