--- chat-mailing-messages

alter table chat_messages add mailing_message_id number(19) references mailing_messages(id);

create index chat_messages_chat_mailing_ix on chat_messages(
    case 
        when mailing_message_id is not null
        then chat_id 
    end, 
    case 
        when mailing_message_id is not null
        then mailing_message_id 
    end
);
