Update to downgrade script

also record the ids of all documents changed