--- ratings

create table ratings (
    id number(19) primary key,
    project_id number(19) not null references projects(id),
    ticket_id number(19) not null references tickets(id),
    client_id number(19) not null references clients(id),
    user_id number(19) not null references users(id),
    state varchar2(32 char) not null,
    value number(10),
    created_at timestamp with time zone not null,
    updated_at timestamp with time zone 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);
