CREATE TABLE system_chats_settings (
    id NUMBER(19) PRIMARY KEY,
    project_id NUMBER(19) NOT NULL REFERENCES projects(id),
    message varchar2(1024),
    lifetime NUMBER(19),
    enabled NUMBER(1),
    deleted NUMBER(1),

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

CREATE SEQUENCE system_chats_settings_id_seq;

CREATE UNIQUE INDEX system_chats_settings_uniq ON system_chats_settings(CASE WHEN deleted = 0 then project_id END , case WHEN deleted = 0 then id END);
