CREATE TABLE tickets_closing_settings (
    id BIGINT PRIMARY KEY IDENTITY (1, 1),
    project_id BIGINT NOT NULL REFERENCES projects(id),
    closing_message nvarchar(1024),
    inactivity_time BIGINT,
    enabled BIT,
    close_bot_dialogs BIT,
    close_user_dialogs BIT,
    [deleted] BIT,

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

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