ALTER TABLE diffalert.messages ADD COLUMN pri_sort float NOT NULL DEFAULT 0;

DROP INDEX diffalert.messages_order_index;

CREATE INDEX messages_order_index on diffalert.messages
    USING btree(task_id, pri_major, pri_minor, pri_sort, id);

DROP INDEX diffalert.messages_filtered_order_index;

CREATE INDEX messages_filtered_order_index on diffalert.messages
    USING btree(task_id, attributes_id, pri_major, pri_minor, pri_sort, id);
