CREATE TABLE client_comments (
    id bigint PRIMARY KEY IDENTITY (1,1),
    client_id BIGINT REFERENCES clients(id),
    project_id BIGINT REFERENCES projects(id),
    author_id BIGINT REFERENCES users(id),
    text NVARCHAR(512),
    channel_type NVARCHAR(100),
    rating_state NVARCHAR(100),
    rating integer,
    edited_by_user_id BIGINT REFERENCES users(id),
    deleted_by_user_id BIGINT REFERENCES users(id),
    deleted BIT default 0,

    created_at DATETIMEOFFSET NOT NULL ,
    edited_at DATETIMEOFFSET,
    deleted_at DATETIMEOFFSET
);

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