It's called a data migration (look it up). Basically, you will:
Some frameworks often offer "features" to help you with data migrations. There are tools to help you execute the code remotely (like fabric in python, or capistrano in ruby), but you could do it manually via ssh as well.
It's probably good practice you commit those data migrations (to have a history of them), but beware they will "rot" in no time, and could be dangerous if executed twice. So, this is a personal opinion: after everything went ok, you should delete them.