Add sql migration to replace time_seen and ensure unique uri and update_order.

- Cannot rely on the ordering based on time_seen column when the values are not unique (e.g. fixed DateTime in tests).