--- ratings

create table ratings (
    id bigint primary key,
    project_id bigint not null references projects(id),
    ticket_id bigint not null references tickets(id),
    client_id bigint not null references clients(id),
    user_id bigint not null references users(id),
    state varchar(32) not null,
    value integer,
    created_at timestamptz not null,
    updated_at timestamptz not null
);

create sequence ratings_id_seq;

create unique index ratings_ticket_uniq
on ratings(ticket_id);

create index ratings_user_index
on ratings(user_id, created_at);

create index ratings_project_index
on ratings(project_id, created_at);
