CREATE TABLE client_comments (
    id BIGINT PRIMARY KEY,
    client_id BIGINT REFERENCES clients(id),
    project_id BIGINT REFERENCES projects(id),
    author_id BIGINT REFERENCES users(id),
    text varchar(512),
    channel_type varchar(100),
    rating_state varchar(100),
    rating integer,
    edited_by_user_id BIGINT REFERENCES users(id),
    deleted_by_user_id BIGINT REFERENCES users(id),
    deleted BOOLEAN default false,

    created_at TIMESTAMP WITH TIME ZONE NOT NULL,
    edited_at TIMESTAMP WITH TIME ZONE,
    deleted_at TIMESTAMP WITH TIME ZONE
);

CREATE SEQUENCE client_comments_id_seq;

create index client_comments_client_comments_id_ticket_id_ix
    on client_comments(id, client_id) where deleted = false;
