Allow the deployment script to be run more than once

This also fixes an issue with inserting specific identities into tables.