You can check out PG::UniqueViolation Problem during 3.1.0.beta4 upgrade - #3 by ahmedeldeep where someone described pretty well what they did.
You’ll need an SSH client, not SFTP. If you’re using Digital Ocean you can use the console on their web site.