
create table identification_rules(
    id bigint primary key not null,
    title varchar(100) not null,
    project_id bigint references projects(id),
    channel_id bigint references channels(id),
    "order" integer not null,
    active boolean not null,
    enabled boolean not null,
    deleted boolean not null,
    success_message text,
    identify_by varchar(100) not null,
    ask_identificator boolean not null,
    identification_question text,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL,
    deleted_at timestamp with time zone
);
create sequence identification_rules_id_seq;
create index identification_rules_project_id on identification_rules(project_id);
create index identification_rules_channel_id on identification_rules(channel_id);


create table client_identifications(
    client_id bigint not null references clients(id),
    last_ticket_id bigint not null references tickets(id),
    status varchar(200) not null,
    secret_word_validator varchar,
    failed_rule_id bigint,
    created_at timestamp with time zone NOT NULL,
    updated_at timestamp with time zone NOT NULL
);
create index client_identifications_client_id on client_identifications(client_id);