Add SQL upgrade for events constraints; put them in sorted order.