Speaking of which, we should probably do this in a transaction (in addition to moving this to branch.sql).