CREATE TABLE tickets_closing_settings (
    id BIGINT PRIMARY KEY,
    project_id BIGINT NOT NULL REFERENCES projects(id),
    closing_message varchar(1024),
    inactivity_time BIGINT,
    enabled BOOLEAN,
    close_bot_dialogs BOOLEAN,
    close_user_dialogs BOOLEAN,
    deleted BOOLEAN,

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

CREATE SEQUENCE tickets_closing_settings_id_seq;

CREATE UNIQUE INDEX tickets_closing_settings_uniq ON tickets_closing_settings(project_id, id) WHERE deleted = false;
