--- ratings

create table ratings (
    id bigint primary key identity (1, 1),
    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 nvarchar(32) not null,
    value integer,
    created_at datetimeoffset not null,
    updated_at datetimeoffset not null
);

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);
